The predict() function will generate the prediction(s) from a model.
Example 1:
# Calculate the predictions from the Sex model of Thumb
# Use the lm() function to specify the model
predict(lm(Thumb ~ Sex, data = Fingers))
# Alt: Save the model into an object first
# then specify the name of the object as the argument
# (this method will produce the same output as the method above)
sex_model <- lm(Thumb ~ Sex, data = Fingers)
predict(sex_model)
Example output (truncated):
Example 2:
To see each prediction in context, you might consider saving the predictions into the data frame as a new column to see more closely what the predict() function is doing.
# Save the predictions back into the data frame
sex_model <- lm(Thumb ~ Sex, data = Fingers)
Fingers$Thumb_predict <- predict(sex_model)
# Select a few rows and the relevant columns to compare
head(select(Fingers, Thumb, Sex, Thumb_predict))
Example output: