I am trying to generate a map using the following data and code:

fileURL <- c("https://drive.google.com/open?id=0B-jAX5hT2D3hNnVtLVhROENKRGs")
ge.planted <- fread(fileURL, na.strings = "NA")
colnames(ge.planted) <- c("region", "type", "crop", "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015")
ge.planted.tidy <- ge.planted%>%
        gather(year, percent.planted, -c(region, type, crop))
ge.planted.tidy$region <- tolower(ge.planted.tidy$region)

states <- map_data("state")
snames <- data.frame(region=tolower(state.name), long=state.center$x, lat=state.center$y)
ge.planted.m <- merge(snames, ge.planted.tidy, by="region", all=TRUE)
ge.planted.m$region <- as.character(ge.planted.m$region)
qplot(long, lat, data=ge.planted.m, geom="map", map = region, fill=percent.planted)

When I run this the following error is returned:

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

I initially thought that I was getting the error because region was a factor and not a character variable, but I have converted it to a character variable (second to last line of code) but the error remains the same with or without it.

closed as unclear what you're asking by Simbamangu, Martin, Chad Cooper, Mapperz May 20 '16 at 16:11

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    In my case, fread throws the following error message: Not positioned correctly after testing format of header row. ch='h'. – fdetsch Apr 19 '16 at 7:48
  • 1
    Please edit your post with example data, your code gives errors at fread(.... Also, at which stage do you get your error with eval, at qplot? – Simbamangu May 20 '16 at 9:07

Browse other questions tagged or ask your own question.