Reputation: 11
I want to plot data in R but I keep getting an error related to facet_grid(-set)
which is: Error in validate_facets(x) : object 'set' not found
install.packages('Tmisc')
library(Tmisc)
data(quartet)
View(quartet)
quartet %>%
group_by(set) %>%
summarize(mean(x), sd(x), mean(y), sd(y), cor(x,y))
ggplot(quartet,aes(x,y))
+ geom_point()
+ geom_smooth(method=lm,se=FALSE)
+ facet_wrap(-set)
> Error in validate_facets(x) : object 'set' not found
Upvotes: 1
Views: 2119
Reputation: 1
It works with the code:
ggplot(quartet,
aes(x,y)) +
geom_point() +
geom_smooth(method=lm,
se=FALSE) +
facet_wrap(~set)
Upvotes: 0
Reputation: 51
Try this code:
install.packages('Tmisc')
library(Tmisc)
data(quartet)
View(quartet)
quartet %>%
group_by(set) %>%
summarize(mean(x), sd(x), mean(y), sd(y), cor(x,y)) %>%
ggplot(quartet,aes(x,y))
+ geom_point()
+ geom_smooth(method=lm,se=FALSE)
+ facet_wrap(~set)
you have to use tilde not dash in front of set because set is an independent variable in the quartet dataset. dash is used to remove a column from selection
Upvotes: 5
Reputation: 9
Try to install the tidyverse package and then this command supposed to be work. since ggplot function is under the tidyverse package
Upvotes: -1