Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Facetting fails with "undefined columns selected" error for non-standard variable names #1067
library(ggplot2) DF <- data.frame( x = 1:10, y = runif(10), `z z` = gl(5, 2), check.names = FALSE ) ggplot(DF, aes(x, y)) + geom_point() + facet_wrap(~ `z z`) ## Error in `[.data.frame`(panels, missing_facets) : ## undefined columns selected ggplot(DF, aes(x, y)) + geom_point() + facet_grid(`z z` ~ .) ## Error in `[.data.frame`(base, names(rows)) : undefined columns selected
you might want to have a look at:
It was the fact that backticks work in aesthetics that led me to believe that they should work in facets too.
For the record, using the standardised version of the column name doesn't work either.
ggplot(DF, aes(x, y)) + geom_point() + facet_wrap(~ z.z)
If no proper fix is possible (that is, making non-standard names correctly draw facets), then It would be nice to provide a more informative error message.
For example, at the start of
library(assertive) assert_all_are_valid_variable_names(attr(terms(facets), "term.labels"))
(The case for
A note in the