Skip to content
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

Error with geom_subplot example in R 3.1.0 #10

Closed
cameronbracken opened this issue May 5, 2014 · 19 comments
Closed

Error with geom_subplot example in R 3.1.0 #10

cameronbracken opened this issue May 5, 2014 · 19 comments

Comments

@cameronbracken
Copy link

I am trying to run the example from the geom_subplot help page

ggplot(casualties, aes(lon, lat), size = 0) +
    geom_subplot2d(aes(lon, lat, 
      subplot = geom_bar(aes(victim, ..count.., fill = victim))), 
      breaks=list(c(60,65,70, 75), c(28, 33, 38)), ref = NULL, width = rel(0.8))

And I get the following error:

Error in layout_base(data, vars, drop = drop) : 
  At least one layer must contain all variables used for facetting

This same error occurs with with every ggsubplot example I've tried to run so far. I've tried with both the CRAN and github version of ggsubplot.

> R.version
               _                           
platform       x86_64-w64-mingw32          
arch           x86_64                      
os             mingw32                     
system         x86_64, mingw32             
status                                     
major          3                           
minor          1.0                         
year           2014                        
month          04                          
day            10                          
svn rev        65387                       
language       R                           
version.string R version 3.1.0 (2014-04-10)
nickname       Spring Dance 

> sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

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

other attached packages:
[1] ggsubplot_0.3.1 ggplot2_0.9.3.1 devtools_1.5   

loaded via a namespace (and not attached):
 [1] colorspace_1.2-4 digest_0.6.4     evaluate_0.5.5   grid_3.1.0       gtable_0.1.2     httr_0.3         labeling_0.2     MASS_7.3-32     
 [9] memoise_0.2.1    munsell_0.4.2    parallel_3.1.0   plyr_1.8.1       proto_0.3-10     Rcpp_0.11.1      RCurl_1.95-4.1   reshape2_1.4    
[17] scales_0.2.4     stringr_0.6.2    tools_3.1.0      whisker_0.3-2   
@cameronbracken
Copy link
Author

This seems to be an issue with R 3.1.0, I am able to run the code just fine in R 3.0.3.

@cameronbracken cameronbracken changed the title Error with geom_subplot example Error with geom_subplot example in R 3.1.0 May 5, 2014
@cpsievert
Copy link

+1

2 similar comments
@grasshoppermouse
Copy link

+1

@RonRichman
Copy link

+1

@mbcasey
Copy link

mbcasey commented Aug 1, 2014

Thanks for sharing. I have the same problem. Does anybody know how to download R 3.0.3 to replace R 3.1.1 on a mac Mac (OS X Server Lion 10.7.5)?

@mbcasey
Copy link

mbcasey commented Aug 1, 2014

Found it!: It is here -http://cran.r-project.org/bin/macosx/old/

@mschubert
Copy link

Does this have any change of getting fixed (soon-ish)?

Relying on an old version of R is not a solution.

@s-fiebig
Copy link

From Stackoverflow (http://stackoverflow.com/questions/20465070/barplots-on-a-map):

Unfortunately, ggsubplot is not very stable. ggplot2 was not designed to be extensible or recursive, so the api between ggsubplot and ggplot2 is very jury rigged. I think entropy will assert itself as R continues to update.
The future plan for development is to implement ggsubplot as a built in part of Hadley's new package ggvis. This will be much more maintainable than the ggsubplot + ggplot2 pairing.
I won't be available to debug ggsubplot for several months, but I would be happy to accept pull requests on github.

@marcionicolau
Copy link

I'm trying to run with R 3.1.2 and in debug process the problem is at line 44 of file sp_layer_build.r

panel

xspan <- range(unlist(data[names(data) %in% .x_aes]), na.rm = TRUE)
yspan <- range(unlist(data[names(data) %in% .y_aes]), na.rm = TRUE)

dbg <- minimal$layers
dbg <- c(dbg, list(geom_point(aes(xspan, yspan),
data = data.frame(xspan, yspan))))
minimal$layers <- dbg

minimal$layers <- list(geom_point(aes(xspan, yspan),

data = data.frame(xspan, yspan)))

panel <- ggplot2::ggplot_build(minimal)$panel

the ocmmaind minimal$layers <- list(...) broken with the message "Error in layout_base(data, vars, drop = drop) : At least one layer must contain all variables used for facetting"

I think that those substitution of layers was causing the error message, because all subplot disappear and left only the points ( no spatial data structure )

My first approach was concatenate both info but does not work

@hadley
Copy link
Collaborator

hadley commented Jul 9, 2015

I'm not exactly sure how I fixed this, but it seems to be ok now.

@hadley hadley closed this as completed Jul 9, 2015
@JT85
Copy link

JT85 commented Aug 1, 2015

@hadley With which version of ggplot2 did you test it? Still doesn't work for me with v1.0.1. I tried to install the dev version from github, but it failed due to a problem with the scales package.

@jailsonfm
Copy link

Dear R users,
I also have problems to use the ggsubplot package.
I updated the R (Version 3.2.1). I cant even reproduce the examples in the package!

@mbcasey
Copy link

mbcasey commented Aug 28, 2015

Has anybody found another way to do what ggsubplot did? I was using it to put little bar plots on different parts of a map. However, I have now got fresh data in to add to the map and cannot face reinstalling an old version of R just to make ggsubplot work. Also, my other programmes need the uptodate R version. Does anybody know of another (reasonably straightforward) way to add bar plots to a map in R ? I was using ggmap with a background map extracted fem the open-street-map resource.

@m-a-j
Copy link

m-a-j commented Aug 28, 2015

For me, it only works when I reinstall ggsubplot in every session - why could that be?

@mbcasey Could you try the code from this issue (#15) please? For some reason, that solved my problems: Like it is done there, I apparently always need to reinstall the package first. If you get error messages like could not find function xy, try ggsubplot:::xy->xy (I got 5 of those). Let me know whether it worked.

@GuangchuangYu
Copy link

@mbcasey maybe subview in ggtree works in your case.

see http://ygc.name/2015/08/31/subview/.

This function is not powerful as in ggsubplot, but it's easy to use and friendly for newbie.

@MattiMeyer
Copy link

I use ggsubplot 0.3.2 with R 3.2.2 and also get the warning:
" At least one layer must contain all variables used for facetting"
That's annoying, because I think it would be very useful by working with large data sets

@pachevalier
Copy link

I also have the same problem and I think we have to find a solution. geom_subplot() would be a really nice feature in ggplot2.

@PetrBechynak
Copy link

+1, I am going to use package plotgooglemaps, which generates pie charts on a google maps.

@GuangchuangYu
Copy link

@PetrBechynak I write my own function to plot pies in map, https://github.com/GuangchuangYu/mapr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests