Step 1 loads the caret package and step 2 reads the data file.
Step 3 converts the outcome variable to a factor. When the outcome variable is a factor, the glm function treats the first factor level as failure and the rest as success. In the present case, we wanted it to treat 0 as failure and 1 as success. To force 0 to be the first level (and hence failure), we specified levels = c(0,1).
Step 4 creates the data partition (we set the random seed to enable you to match your results with those that we display).
Step 5 builds the logistic regression model and stores it in the logit variable. Note that we have specified the data to be only the cases in the training partition.
Step 6 displays important information about the model. ...