data not recognized as data.frame
Closed this issue · 2 comments
Hello. Sorry to bother you. I'm having issues implementing the library. I tried the example from the documentation but I get the error:
Error in alpha(data$fill, data$alpha) :
Data must either be a data frame or a matrix
Thanks for putting this library out there, I would really like to use it. This is my script:
library(ggplot2)
library(ggmosaic)
library(NHANES)
df.1 <- data.frame(NHANES, stringsAsFactors = F)
ggplot(data = df.1) +
geom_mosaic(aes(weight = Weight, x = product(SleepHrsNight), fill=factor(SleepHrsNight)), na.rm=TRUE) +
labs(x="Hours of sleep a night ", title='f(SleepHrsNight)') + guides(fill=guide_legend(title = "SleepHrsNight", reverse = TRUE))
What am I missing?
@jotasolano could you add your session info? - it seems we have overlooked a dependency, and updating to a newer version of (some of) the package(s) we depend on would solve the issue.
Based on this particular error message looks like it might be the scales package.
@heike I re-installed scales
and it did it!. Thank you so much for your quick reply. I'll attach the session regardless in case someone else runs with the same issue.
R version 3.3.1 (2016-06-21)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.6 (El Capitan)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] NHANES_2.1.0 psych_1.6.9 GGally_1.3.0 ggmosaic_0.1.2 productplots_0.1.1
[6] ggthemes_3.4.0 ggplot2_2.2.1 dplyr_0.5.0.9000
loaded via a namespace (and not attached):
[1] Rcpp_0.12.9.3 plotly_4.5.6 magrittr_1.5 mnormt_1.5-5
[5] munsell_0.4.3 colorspace_1.2-6 viridisLite_0.1.3 R6_2.2.0
[9] httr_1.2.1 plyr_1.8.4 tools_3.3.1 parallel_3.3.1
[13] grid_3.3.1 gtable_0.2.0 DBI_0.5-1 htmltools_0.3.5
[17] lazyeval_0.2.0.9000 assertthat_0.1 digest_0.6.12 tibble_1.2
[21] RColorBrewer_1.1-2 purrr_0.2.2 tidyr_0.6.1 base64enc_0.1-3
[25] htmlwidgets_0.8 labeling_0.3 scales_0.4.1 reshape_0.8.5
[29] jsonlite_1.3 foreign_0.8-66