I keep on getting ggplot2 error

ggplot(datasaurus_dozen, aes(x=x,y=y,colour=dataset))+geom_point() +theme_void()+theme(legend.position = "none")+facet_wrap(-dataset,ncol=3)
Error in validate_facets(x) : object 'dataset' not found

I'm now learning R, pls any help on how to solve this error?

What is dataset? Also, within facet_wrap you should use a ~before that column that defines the partitioning of the data, not -.

Thank you for replying. I'm using the Anscombe's quartet dataset.

But what code do you use to assign a value to dataset? Is dataset supposed to be a column in datasaurus_dozen? That is what is implied when you write colour = dataset but R cannot find dataset.

The datasaurus_dozen data set is from the datasauRus package. The dataset variable has the names of 13 different data sets.

I think your problem, besides the ~, is that the + sign must come at the end of the line, not at the start of the next line.

BTW, the use of spaces would make your code a bit more readable

ggplot(datasaurus_dozen, aes(x = x, y = y, colour = dataset)) + geom_point() +
theme_void() + theme(legend.position = "none") + facet_wrap(~ dataset, ncol = 3)

thank you guys.. problem solved. now help with this...

ggplot(quartet, aes(x, y)) + geom_point() + geom_smooth(method = 1m, se=FALSE) + facet_wrap(~set)..

lm, as in linear model, not 1m

If you have new questions, please mark this topic as solved and start a new one.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.