Facet_list; object not defined

Hello, I am just learning r and I am having issues running this ; ggplot(quartet,aes(x,y) + geom_point() + geom_smooth(method=1m, se=FALSE) + facet_wrap(-set)) i have been getting this response ; ggplot(quartet,aes(x,y) + geom_point() + geom_smooth(method=1, se=FALSE) + facet_wrap(-set))
Error in as_facets_list(x) : object 'set' not found.

Please, how do I define facet_wrap issues here? Thank you as you help

library(ggplot2)
p <- ggplot(mpg, aes(displ, hwy)) + geom_point()
p + facet_wrap(~ cyl)

Hi technocrat, thank you for your reply.

Can you kindly explain further, your answer to my question, please? "object not defined is understood" However, the variables you gave here ; "cyl", is it universal? I mean can I use it anytime I am defining facet_wrap.

Thanks

"cyl", is it universal?

No, it's specific to the cars data set (or any other data set containing the same name, such as the mtcars built-in).

Your quartet dataset must have variables named x, y, and set (check with colnames(quartet) and facet_wrap must have ~ set, not -set.

2 Likes

Thank you, Technocrat.

I am humbled by your willingness to help.

Keep winning and I hope you will always oblige at my request for help.

1 Like

My answers can be obscure—they are meant to raise questions, so always bring them.

OK, I will. Thank you

1 Like

This topic was automatically closed 21 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.