I'm trying to plot the lm line using this code
df <- data.frame(c1=factor(c(1,1,1,1,2,2,2,2,3,3,3,3)),c2=c(65,42,56,75,43,43,21,23,12,12,21,11)) p <- ggplot(aes(x=c1,y=c2),data=df) p + geom_point() + geom_smooth(method="lm") But the lm line is not shown. Am I missing something?
factor? Change it tonumericand you should be able to get the linefactor, setaes(group = 1).