YuLab-SMU / scatterpie

:art: scatter pie plot
https://cran.r-project.org/package=scatterpie
60 stars 16 forks source link

"the argument has already been evaluated" error #10

Closed codyschulz closed 6 years ago

codyschulz commented 6 years ago

When I attempt to run the CRAN example on my machine (scatterpie 0.1.0, Windows 10, R 3.4.4, ggplot2 2.2.1), I receive the following error: "Error in (function (x, strict = TRUE) : the argument has already been evaluated"

Any ideas about what might be going on?

codyschulz commented 6 years ago

Just noticed that scatterpie is compatible with the dev version of ggplot2. Will try that. Sorry.

codyschulz commented 6 years ago

Turns out that with the development version of ggplot2, when the following code is run:

library(ggplot2)
d <- data.frame(x=rnorm(5), y=rnorm(5))
d$A <- abs(rnorm(5, sd=1))
d$B <- abs(rnorm(5, sd=2))
d$C <- abs(rnorm(5, sd=3))
ggplot() + geom_scatterpie(aes(x=x, y=y), data=d, cols=c("A", "B", "C")) + coord_fixed()

the following error is thrown:

Error in `[.data.frame`(data, , xvar) : undefined columns selected

Edit: The code works when I use ggplot2 2.2.1 and the scatterpie December 2017 commit.

cperk commented 6 years ago

How do you get the December 2017 commit? I also get that error.

GuangchuangYu commented 6 years ago

it works with latest versions.

> sessionInfo()                                                     
R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Arch Linux

Matrix products: default
BLAS: /usr/lib/R/lib/libRblas.so
LAPACK: /usr/lib/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] scatterpie_0.1.2     ggplot2_3.0.0        RevoUtils_11.0.1    
[4] rvcheck_0.1.0        rmarkdown_1.10       roxygen2_6.1.0      
[7] magrittr_1.5         RevoUtilsMath_11.0.0

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.18     compiler_3.5.1   pillar_1.3.0     plyr_1.8.4      
 [5] bindr_0.1.1      tools_3.5.1      digest_0.6.15    evaluate_0.11   
 [9] tibble_1.4.2     gtable_0.2.0     pkgconfig_2.0.2  rlang_0.2.2     
[13] commonmark_1.5   bindrcpp_0.2.2   withr_2.1.2      stringr_1.3.1   
[17] dplyr_0.7.6      xml2_1.2.0       knitr_1.20       rprojroot_1.3-2 
[21] grid_3.5.1       tidyselect_0.2.4 glue_1.3.0       R6_2.2.2        
[25] tidyr_0.8.1      tweenr_0.1.5     purrr_0.2.5      units_0.6-0     
[29] MASS_7.3-50      backports_1.1.2  scales_1.0.0     htmltools_0.3.6 
[33] assertthat_0.2.0 ggforce_0.1.3    colorspace_1.3-2 labeling_0.3    
[37] stringi_1.2.4    lazyeval_0.2.1   munsell_0.5.0    crayon_1.3.4    
> 
jeaninebr commented 4 years ago

I get the same error message still, using the latest R version 3.6 and the dev version of ggplot. I think the error must be somewhere within the geom_scatterpie() function, and how it plots the aesthetics? This is the head of my data set, A,B,C are the proportion that I would want to display in a pie chart. x and y are coordinates, first row is the site ID.

site x y A B C 1 613496 267409 0.75 0.25 0.00 2 609445 225330 0.50 0.25 0.25 3 605997 220876 0.50 0.25 0.25 4 607744 250786 0.50 0.25 0.25 5 662647 195819 0.50 0.25 0.25 6 664315 212930 0.50 0.25 0.25

This is the error message:

Error in [.data.frame(data, , xvar) : undefined columns selected

Thank you so much for your help!

GuangchuangYu commented 4 years ago

image

jeaninebr commented 4 years ago

It seems to work fine for you, it doesn't for me. Still get the error message, even when I copy your exact code. It might be an issue with a package being masked. I'll try to figure it out and let you know. Thanks for your effort though!