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

ggsubplot error with R 3.2.1 #15

Open
mike-joyce opened this issue Jul 20, 2015 · 3 comments
Open

ggsubplot error with R 3.2.1 #15

mike-joyce opened this issue Jul 20, 2015 · 3 comments

Comments

@mike-joyce
Copy link

I saw some compatibility issues were closed, so I tried to run the Afghanistan casualties example code. I'm getting an error:

Error in get(x, envir = this, inherits = inh)(this, ...) : 
  could not find function "aesply"

Here's the code I'm trying to run:

library(devtools)
dev_mode(on=T)

install_github("garrettgman/ggsubplot")

library(ggplot2)
library(maps)
library(plyr)

# getbox by Heike Hoffman, 
# https://github.com/ggobi/paper-climate/blob/master/code/maps.r
getbox <- function (map, xlim, ylim) {
  # identify all regions involved
  small <- subset(map, (long > xlim[1]) & (long < xlim[2]) & (lat > ylim[1]) & (lat < ylim[2]))
  regions <- unique(small$region)
  small <- subset(map, region %in% regions)  

  # now shrink all nodes back to the bounding box
  small$long <- pmax(small$long, xlim[1])
  small$long <- pmin(small$long, xlim[2])
  small$lat <- pmax(small$lat, ylim[1])
  small$lat <- pmin(small$lat, ylim[2])

  # Remove slivvers
  small <- ddply(small, "group", function(df) {
    if (diff(range(df$long)) < 1e-6) return(NULL)
    if (diff(range(df$lat)) < 1e-6) return(NULL)
    df
  })

  small
}


## map layer
## adapted from map_nasa:
# https://github.com/ggobi/paper-climate/blob/master/code/maps.r

# assembling data
world <- map_data("world")

# building afghanistan layer
afghanistan <- getbox(world, c(60,75), c(28, 39))
map_afghanistan <- list(
  geom_polygon(aes(long, lat, group = group), data = afghanistan, 
               fill = "white", colour = "black", inherit.aes = FALSE, 
               show_guide = FALSE),
  scale_x_continuous("", breaks = NULL, expand = c(0.02, 0)),
  scale_y_continuous("", breaks = NULL, expand = c(0.02, 0)))


## 2d bin with bar chart subplots displaying data in each region
ggplot(casualties) +
  map_afghanistan +
  geom_subplot2d(aes(lon, lat,
                     subplot = geom_bar(aes(victim, ..count.., fill = victim))),
                 bins = c(15,12), ref = NULL, width = rel(0.8)) +
  coord_map()+
  theme(legend.position = "right")
@ginolhac
Copy link

I have the exact same error, also using the latest version of ggsubplot 0.3.1.9000 and R 3.2.1.

@m-a-j
Copy link

m-a-j commented Aug 2, 2015

Using R 3.1.1, and I'm getting your error message as well.
I found out that this particular error can be (temporarily) solved through commands like ggsubplot:::aesply->aesply (i.e. the functions are there, but seem not to be loaded properly)... (I'd prepare a pull request if I knew how to make all those functions globally visible at once)

@ns-1m
Copy link

ns-1m commented Aug 27, 2015

I got this error in R-3.2.1 Mac OS X in the R scripts above and also in this scripts posted here,

http://stackoverflow.com/questions/16028659/plots-on-a-map-using-ggplot2

  • map_afghanistan +
  • geom_subplot2d(aes(lon, lat,
  • .... [TRUNCATED] 
    

Error in ls(object@layer) :
2 arguments passed to .Internal(ls) which requires 3

Using this master ggsubplot, I the same original error.

Using binwidth 0.905
Using binwidth 0.754
Error in get(x, envir = this, inherits = inh)(this, ...) :
could not find function "aesply"

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

4 participants