Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7807453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:51:34+00:00 2026-06-02T02:51:34+00:00

I am working through making cholorpleth’s (a learning project I started HERE ). I

  • 0

I am working through making cholorpleth’s (a learning project I started HERE). I once asked about plotting text on a map (HERE) on SO. I’m now trying to plot names on the same map but with it faceted but keep getting an error:

Error in eval(expr, envir, enclos) : object 'group' not found

Which I take to me that R hates me and I’m an imbecile 🙂 traceback is ~ 5 miles long so that’s not a help either. If you take out the geom_text everything runs fine.

PS I know about the new geom_map and have been playing with that as well but this is a separate problem that’s bugging me.

Thank you in advance for your help.

#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())
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:51:35+00:00Added an answer on June 2, 2026 at 2:51 am

    In the first ggplot() call, you map group to group. This mapping is then passed on to each layer, therefore ggplot complains when it can’t find group in the centroids data used in your geom_text layer.

    Unmap it using groups=NULL in the geom_text call, and it is fine:

    ggplot(map.data2, aes(long, lat, group=group)) +  
       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)+
       geom_text(data=centroids, aes(x=long, y=lat, 
         label=subregion, angle=angle, group=NULL), size=3) +   # THIS HAS CHANGED!
       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())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In working through the issues with another question, I've found text files with embedded
I am working on making all of our JS code pass through jslint, sometimes
I am working on making an entity framework project more scalable to suit our
To help me learn Haskell, I am working through the problems on Project Euler.
I was making a java gui application through netbeans IDE. All was working fine
I've tried working through some previous answers, but they aren't making a lot of
Alright so in the project I am working on I am making a hard
Working through trace tables and wanted to check to see if my results where
Still working through JQuery to get data and repopulate portions of a page. Right
I am working through the mapping plugin example on the Knockoutjs website. This is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.