Step 1 loads the MASS and caret packages and step 2 reads the data.
Step 3 converts our outcome variable to a factor.
Step 4 partitions the data. We set the random seed to enable you to match your results with those that we display.
Step 5 builds the LDF model. We pass the predictors as the first argument and the outcome values as the second argument to the lda function. We can also supply the details as a formula--see the following There's more... section.
Step 6 uses the predict function to generate the predictions for the training partition. We pass the model and predictor variables. The class component of the returned object from the predict function contains the predicted class values. We then use the table function to ...