I have two non-empty dataframes: training
and testing
. Each of these dataframes has two columns: Y
and X
, in this order. I have applied linear regression analysis to training
as follows:
m <- lm(Y ~ X, data = training)
I would like to apply the coefficients resulting from this fitting to the data in testing
to obtain the same types of information available in the object m
for purposes of further analysis and data visualization. How can I do this?
See the
predict.lm
function: