Showing fitted values with R and dplyr
I have the data frame DF . I am using R and dplyr to analise it. DF contains: > glimpse(DF) Observations: 1244160 Variables: $ Channel (int) 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0... $ Row (int) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,... $ Col (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1... $ mean (dbl) 776.0667, 786.6000, 833.4667, 752.3333, 831.6667, 772.9333... I fit it with: Fit <- DF %>% group_by(Channel) %>% do(fit = lm(mean ~ Col + poly(Row, 2), data = .)) How can I get another column in DF with the data (given Channel , Row and