wilkelab / ggridges

Ridgeline plots in ggplot2
https://wilkelab.org/ggridges
GNU General Public License v2.0
411 stars 31 forks source link

Quosure/Formula Error #27

Closed nick-ulle closed 5 years ago

nick-ulle commented 6 years ago

A student in a class I'm teaching encounters an error for the following example:

library(ggplot2)
library(ggridges)

set.seed(10)

df = data.frame(
  x = rnorm(100),
  y = rep(letters[1:10], each = 10)
)

ggplot(df, aes(x, y)) + geom_density_ridges()

# > Picking joint bandwidth of 0.45
# 
# Don't know how to automatically pick scale for object of type quosure/formula. Defaulting to continuous.
# 
# Error in data.frame(..., check.names = FALSE) : 
# 
#   参数值意味着不同的行数: 2, 5120

I'm not able to reproduce the error on my machine. The sessionInfo() from the student's machine is

R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936  LC_CTYPE=Chinese (Simplified)_China.936   
[3] LC_MONETARY=Chinese (Simplified)_China.936 LC_NUMERIC=C                              
[5] LC_TIME=Chinese (Simplified)_China.936    

attached base packages:
  [1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
  [1] ggridges_0.5.1 ggplot2_2.2.1  rlang_0.2.2   

loaded via a namespace (and not attached):
[1] Rcpp_0.12.14     grid_3.4.4       plyr_1.8.4       gtable_0.2.0     scales_0.5.0     lazyeval_0.2.1  
[7] labeling_0.3     tools_3.4.4      munsell_0.4.3    compiler_3.4.4   colorspace_1.3-2 tibble_1.3.4   

Any guidance on how to solve this problem is much appreciated!

clauswilke commented 6 years ago

Can the student install the reprex package, run the example, and post the output here? The most likely scenario is a typo in the code the student ran, e.g. they didn’t actually call the data frame df or they forgot to execute that line.

Because they’re running an outdated version of ggplot2, it’s difficult for me to know exactly what caused this error message, but I believe using df without defining it could be the reason.

nick-ulle commented 6 years ago

I ran the code on their machine myself -- it's not a problem with df being undefined.

I will have them update ggplot2 and see if the example still causes an error.

nick-ulle commented 5 years ago

Updating to the latest version of ggplot2 solved the issue.

Thanks!