I have a data frame with a column of models and I am trying to add a column of predicted values to it. A minimal example is :
exampleTable <- data.frame(x
Eh, this is only slightly better:
answer =
exampleTable %>%
group_by(groups) %>%
do(lm( y ~ x , data = .) %>%
predict %>%
data_frame(prediction = .)) %>%
bind_cols(exampleTable)
I was hoping this would work but it didn't.
answer =
exampleTable %>%
group_by(groups) %>%
mutate(prediction =
lm( y ~ x , data = .) %>%
predict)