swirldev / swirl_courses

:mortar_board: A collection of interactive courses for the swirl R package.
http://swirlstats.com
Other
4.29k stars 7.25k forks source link

Statistical_Inference/Hypothesis_Testing/conf_5pct_left.R #243

Open cryptomanic opened 8 years ago

cryptomanic commented 8 years ago

I think the layer function of ggplot2 is not used properly. I am getting this error : Error in layer("area", mapping = aes(x = ifelse(x > qnorm(0.95, sd = 2), : unused argument (geom_params = list(fill = "red", alpha = 0.5))

seankross commented 8 years ago

See swirldev/swirl#397

jpabroeren commented 8 years ago

Somehow, this doesn't work for me. Has anyone any suggestions? I'm willing to comment out anything, but where (or how) can I download the complete zip to change it?

cryptomanic commented 8 years ago

Replacing this code

suppressWarnings(g <- g+ layer("area",mapping = aes(x=ifelse(x>qnorm(.95,sd=2),x,NA)), geom_params=list(fill="red",alpha=.5)) )

With

suppressWarnings(g <- g+ layer("area",stat = "identity",position = "identity",mapping = aes(x=ifelse(x>qnorm(.95,sd=2),x,NA)), params=list(fill="red",alpha=.5,na.rm=TRUE)) )

Works very well.

studiology commented 8 years ago

see fix in PR #242 EDIT: now merged, so this shouldn't be an issue any longer with ggplot2 above v1.0.1

medinaale commented 8 years ago

I have a similar issue with the following session info

sessionInfo() R version 3.2.4 (2016-03-10) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: OS X 10.10.5 (Yosemite)

locale: [1] C/UTF-8/C/C/C/C

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

other attached packages: [1] gridExtra_2.2.1 ggplot2_2.1.0 gProfileR_0.5.3

loaded via a namespace (and not attached): [1] compiler_3.2.4 colorspace_1.2-6 scales_0.4.0 plyr_1.8.3
[5] gtable_0.2.0 Rcpp_0.12.4 grid_3.2.4 munsell_0.4.3

The error is unused argument (alpha = 1)

The same ggplot2 instruction runs in an R older version.