Ich arbeite durch das Bilden cholorpleths (ein Lernprojekt, das ich begann HERE). Ich fragte einmal nach dem Zeichnen von Text auf einer Karte (HERE) auf SO. Ich versuche jetzt Namen auf der gleichen Karte zu zeichnen, aber mit ihm facettierten aber halten einen Fehler bekommen:Grundstücksbezirksnamen auf facettiertem Zustandsplan (ggplot2)
Error in eval(expr, envir, enclos) : object 'group' not found
Was ich mir nehmen, dass R hasst mich, und ich bin ein Dummkopf :) traceback
ist ~ 5 Meilen lang, das ist auch keine Hilfe. Wenn Sie die geom_text
herausnehmen, läuft alles gut.
PS Ich weiß über die neue geom_map
und habe damit auch gespielt, aber das ist ein separates Problem, das mich nervt.
Vielen Dank im Voraus für Ihre Hilfe.
#Load three data sets from my dropbox
load(url("http://dl.dropbox.com/u/61803503/Names/cholo.RData"))
#view head of the three data frames
lapply(list("map.data2"=map.data2, "ny"=ny, "centroids"=centroids), head)
####################################################################
# map.data2 contains the filling information (test scores) #
# ny contains the lat and long information for plotting boundaries #
# centroids contains the information for plotting labels #
####################################################################
#Load Necessary Libraries
library(ggplot2); library(maps); library(RColorBrewer); library(scales)
ggplot(map.data2, aes(long, lat, group=group)) + #plot pass rates math
geom_polygon(aes(fill=level), colour=alpha('white', 1/2), size=0.2) +
geom_polygon(data=ny, colour='black', fill=NA) +
scale_fill_brewer(palette='RdYlBu', guide = guide_legend(title =
"Percent Passing"))+
facet_grid(.~Subject)+
#annotate(data = "text", label = centroids$subregion, x = centroids$long,
# y = centroids$lat, size = 2, colour = "black") +
geom_text(data=centroids, aes(x=long, y=lat,
label=subregions, angle=angle), size=3) +
opts(title = "
New York State Counties Passing Rate \non Elementary ELA Assessments") +
opts(axis.text.x = theme_blank(), axis.text.y = theme_blank(),
axis.ticks = theme_blank())+
opts(legend.background = theme_rect()) +
scale_x_continuous('') + scale_y_continuous('') +
labs(title = "legend title") + theme_bw()+
opts(axis.line=theme_blank(),axis.text.x=theme_blank(),
axis.text.y=theme_blank(),axis.ticks=theme_blank(),
axis.title.x=theme_blank(), legend.position="bottom",
axis.title.y=theme_blank(),
panel.background=theme_blank(),panel.grid.major=theme_blank(),
panel.grid.minor=theme_blank(),plot.background=theme_blank())
Ich weiß, dass dies nicht gerade gering ist, aber ich weiß, dass in ggplot2 wichtig ist, Schichtung und wollte sicher etwas machen, war ich Doing später beeinflusste nicht die 'geom_text' –