Enter below the R command to create the training data set. C…