I am trying to replicate the example here (sthda.com) using the following code:
# Change point shapes and colors manually
ggplot(mtcars, aes(x=wt, y=mpg, color=cyl, shape=cyl)) +
geom_point() +
geom_smooth(method=lm, se=FALSE, fullrange=TRUE)+
scale_shape_manual(values=c(3, 16, 17))+
scale_color_manual(values=c('#999999','#E69F00', '#56B4E9'))+
theme(legend.position="top")
The example on that web page says that code should produce the following result:
But when I run it in R, I get the following error:
"Error: Continuous value supplied to discrete scale"
Does anyone know what could be wrong with this code? Or why I am getting a different result than the example?
If someone could run the sample code and tell me if they get the same error I would be very grateful.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…