I am just trying to make a simple plot using mtcars and ggplot:
ggplot(data=mtcars, aes(x=mpg,y=hp))+geom_line(mpg,hp,col=cyl)
but I get the error:
ggplot doesnt know how to deal with class numeric
What is going on?
My suggestion is to specify all aesthetics in one place and to coerce cyl to factor for colour coding as categorial variable.
ggplot(data=mtcars, aes(x=mpg, y=hp, colour=factor(cyl))) + geom_line()
will create

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With