-
-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error using facet_grid() with more than one faceting variable - invalid 'times' argument #66
Comments
incredible reprex! #ty! will take a look (likely at the tail end of the week) |
@hrbrmstr Did you ever figure this out? |
I believe this error occurs when the data does not contain every combination of the two However, if you include all the missing combination rows with a value of zero you get one of two different errors depending on whether or not library(waffle)
library(tidyverse)
xdf <- tibble(
parts = factor(rep(month.abb[1:3], 3), levels=month.abb[1:3]),
values = c(10, 20, 30, 6, 14, 40, 30, 20, 10),
fct = c(rep("Thing 1", 3), rep("Thing 2", 3), rep("Thing 3", 3)),
fct2 = c(rep('a', 4), rep('b', 5))
) %>%
bind_rows(
tribble(
~parts, ~values, ~fct, ~fct2,
"Jan", 0, "Thing 1", "b",
"Feb", 0, "Thing 1", "b",
"Mar", 0, "Thing 1", "b",
"Feb", 0, "Thing 2", "a",
"Mar", 0, "Thing 2", "a",
"Jan", 0, "Thing 3", "a",
"Feb", 0, "Thing 3", "a",
"Mar", 0, "Thing 3", "a"
)
)
ggplot(xdf, aes(fill = parts, values = values)) +
geom_waffle(color = "white", size = 1.125, n_rows = 10) +
facet_grid(fct2 ~ fct) +
scale_x_discrete(expand = c(0,0)) +
scale_y_discrete(expand = c(0,0)) +
coord_equal() +
labs(title = "Faceted Waffle Geoms") +
theme_enhance_waffle()
ggplot(xdf, aes(fill = parts, values = values)) +
geom_waffle(color = "white", size = 1.125, make_proportional = TRUE, n_rows = 10) +
facet_grid(fct2 ~ fct) +
scale_x_discrete(expand = c(0,0)) +
scale_y_discrete(expand = c(0,0)) +
coord_equal() +
labs(title = "Faceted Waffle Geoms") +
theme_enhance_waffle()
|
@nsgrantham for completeness, I believe if you use an artificially small number (e.g. 1E-6) instead of zero (0), this actually works. |
Just to help expand on this, here's a working sample based on @JasonAizkalns's suggestion
|
While
facet_wrap()
works like a charm,facet_grid()
leads to an error when used with a second (or more) faceting variable.I attached a reprex below.
Thanks for a great package!
Created on 2019-07-24 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: