-
Notifications
You must be signed in to change notification settings - Fork 15
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
Code Gives this Error #16
Comments
I had someone else have the same error but I don't have a reproducible example. Do you have one? |
Unfortunately, I don't. I'll look into it more |
I think I've figured out what the issue is here. When the grouping variable is numeric, I tend to get this error. But if I convert it to a character it seems to fix things. Reproducible example of failing and working code below! Broken because of numeric grouping variable: library(ggstream)
library(ggplot2)
library(dplyr)
blockbusters %>%
mutate(genre2 = if_else(genre == 'Action', 1,
if_else(genre == 'Adventure', 2,
if_else(genre == 'Animation', 3,
if_else(genre == 'Comedy', 4,
if_else(genre == 'Drama', 5, 6)))))) %>%
ggplot(aes(year, box_office, fill = genre2)) +
geom_stream() Working because grouping variable is a character: library(ggstream)
ggplot(blockbusters, aes(year, box_office, fill = genre)) +
geom_stream() |
I'm getting this error and it seems to be because set.seed(123)
library(ggplot2)
library(ggstream)
test_bug <- function(n_observations, n_grid) {
data.frame(
x = rep(1:n_observations, 4),
y = rnorm(4 * n_observations),
fill = rep(letters[1:4], each = n_observations)
) %>%
ggplot(aes(x = x, y = y, fill = fill)) +
geom_stream(n_grid = n_grid)
}
# Fails
test_bug(n_observations = 100, n_grid = 101)
# Works
test_bug(n_observations = 100, n_grid = 102)
# Fails
test_bug(n_observations = 1000, n_grid = 1019)
# Works
test_bug(n_observations = 1000, n_grid = 1020) |
This worked for me. But also being especific with the exact number of observations inside |
So the workaround is: ggplot(
[...]
n_grid = length(df[[1]])*1.2
) Worked for me. Thanks! |
Any idea why it's giving this error?
Error in data.frame(x = full_values$x, y = yy[, iStream * 2], group = as.integer(.group)) :
arguments imply differing number of rows: 1000, 1126, 1
The text was updated successfully, but these errors were encountered: