2015-07-18 1 views
6

Die Version von ggsubplot von CRAN verfügbar ist nicht kompatibel mit neueren Versionen von R (zB 3.1.1) und gibt überFunktioniert ggsublplot mit R 3.2.1+? Es ist ein Problem Leute bemerkt haben in Stackoverflow Fragen

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

einen Fehler die ggsubplot Beispiele ausgeführt wird:

und GitHub Fragen:

Allerdings waren die GitHub Themen geschlossen früher in diesem Monat (2015.07.09), was mich optimistisch, dass ggsubplot würde mit R funktionieren würde 3.2.1+

CRAN hosts version 0.3.2 of ggsubplot (released 2013-12-14) so habe ich Paket devtools verwendet, um ggsublplot von GitHub zu installieren.

Ich versuchte, das Afghanistan Opfer Beispielcode zu laufen, aber ich bin jetzt eine andere Störung zu erhalten:

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

Gibt es etwas, das ich diese Arbeit machen tun kann?

Wie bestätige ich auch, welche Version von ggsublplot ich verwende?

Der Code habe ich versucht folgt:

## install.packages("devtools") 

library(devtools) 

dev_mode(on=T) 

install_github("garrettgman/ggsubplot") 

library(ggplot2) 
## library(ggsubplot) - I just loaded this, right? 
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") 
+0

In meinem Fall (und ich verwende eine viel ältere R-Version!) Es funktioniert nur, wenn ich das Ggsublot Paket mit jeder neuen Sitzung neu installieren. – maj

Antwort

0

Es scheint, dass Paket ggsubplot nicht mehr eingehalten wird.

Message on CRAN (as of 2016-12-23):

Package ‚ggsubplot‘ wurde aus dem CRAN Repository entfernt.

Früher verfügbare Versionen können aus dem Archiv bezogen werden.

Archiviert am 2016-01-11 wie vom Betreuer [email protected] angefordert.

Auf GitHub (https://github.com/garrettgman/ggsubplot), das letzte Commit stammt aus 2015-07-09.

Die Installation von GitHub unter R 3.3.2 mit devtools::install_github('garrettgman/ggsubplot') ist fehlgeschlagen mit einer Fehlermeldung über die fehlende Funktion eval.

Verwandte Themen