Scatterplot<-ggplot(
diamonds[sample(nrow(diamonds), 1000), ],
aes(carat, price, colour=clarity)
)+
geom_point(position="jitter", alpha=0.6)+
facet_grid(~cut) +
scale_x_continuous(breaks=seq(0, 5, 1)) +
geom_boxplot(alpha=0, colour="black") +
scale_color_brewer(palette = "Set1")
plot(Scatterplot)
I cannot find any clue about this warning. Anyone knows? Please check the picture:
You can get around it with adding group = 1
:
Scatterplot<-ggplot(
diamonds[sample(nrow(diamonds), 1000), ],
aes(carat, price, colour=clarity, group = 1)
)+
geom_point(position="jitter", alpha=0.6)+
facet_grid(~cut) +
scale_x_continuous(breaks=seq(0, 5, 1)) +
geom_boxplot(alpha=0, colour="black") +
scale_color_brewer(palette = "Set1")
plot(Scatterplot)
This removes the error. However, I did not check if your overall approach to this plot makes sense (see comments).
Regarding why group = 1
is necessary: I would recommend this chapter in R for Data Science.
This happened to me because the x
column wasn't character (it was numeric).
Simply mutate
to character i.e.
mutate(myvariable = as.character(myvariable))
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