How to apply a trained Random Forest model to a new data set in R? So I have a data set that is essentially football players statistics in 2017 and 2018. I have trained my model to use the 2017 data to predict the 2018 number of touchdowns. My code is below:

set.seed(1)
data.rf &lt;- randomForest(2018_td ~ ., data = data, proximity = TRUE)


In my  data set, I had the actual # of touchdowns in 2018, and trained a random forest algorithm to predict that value. Now, I want to apply the trained random forest on the same 2018 data set, but to predict 2019 # of TD, that I don't have.

I'm not sure if I'm missing something or if I have a fundamentally wrong understanding of how RF works. How would I go about predicting those 2019 values from my data.rf model?
You need to setup another data frame that has the unlabeled 2019 observations. Assuming you have multiple predictors, your new data would have the exact same columns as your 2018 data but with no 2019_td column (since you presumably don't know anything about the 2019 season). That is, the players in 2019 that you wish to predict on, along with their predictors, but no target column.

Once you have the data frame, you can use predict(trained_model, newdata) to score your new predictions.

Edit: As an aside, you have data that is influenced by time. What happens if a player gets injured next season? What about trends in the players performance?