Skip to content

Commit

Permalink
for cran submission, need envir=environment() in data() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
alamstein-trulia committed Oct 27, 2014
1 parent 07485f9 commit af67994
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion R/choroplethr_wdi.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#' @importFrom WDI WDI
choroplethr_wdi = function(code="SP.POP.TOTL", year=2012, title="", buckets=7, zoom=NULL)
{
data(country.regions, package="choroplethrMaps")
data(country.regions, package="choroplethrMaps", envir=environment())
if (is.null(title))
{
title = paste0("WDI Indicator ", code, " for year ", year)
Expand Down
2 changes: 1 addition & 1 deletion R/country.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ CountryChoropleth = R6Class("CountryChoropleth",
# initialize with a world map
initialize = function(user.df)
{
data(country.map, package="choroplethrMaps")
data(country.map, package="choroplethrMaps", envir=environment())
super$initialize(country.map, user.df)

if (private$has_invalid_regions)
Expand Down
8 changes: 4 additions & 4 deletions R/county.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ CountyChoropleth = R6Class("CountyChoropleth",
# initialize with us state map
initialize = function(user.df)
{
data(county.map, package="choroplethrMaps")
data(county.regions, package="choroplethrMaps")
data(county.map, package="choroplethrMaps", envir=environment())
data(county.regions, package="choroplethrMaps", envir=environment())
# USAChoropleth requires a column called "state" that has full lower case state name (e.g. "new york")
county.map$state = merge(county.map, county.regions, sort=FALSE, by.x="region", by.y="region")$state.name
super$initialize(county.map, user.df)

# by default, show all states on the map
data(state.map, package="choroplethrMaps")
data(state.map, package="choroplethrMaps", envir=environment())
private$zoom = unique(state.map$region)

if (private$has_invalid_regions)
Expand All @@ -35,7 +35,7 @@ CountyChoropleth = R6Class("CountyChoropleth",
# remove regions not on the map before doing the merge
self$user.df = self$user.df[self$user.df$region %in% county.regions$region, ]

data(county.regions, package="choroplethrMaps")
data(county.regions, package="choroplethrMaps", envir=environment())
self$user.df$state = merge(self$user.df, county.regions, sort=FALSE, all.X=TRUE, by.x="region", by.y="region")$state.name
self$user.df = self$user.df[self$user.df$state %in% private$zoom, ]
self$user.df$state = NULL
Expand Down
2 changes: 1 addition & 1 deletion R/state.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ StateChoropleth = R6Class("StateChoropleth",
# initialize with us state map
initialize = function(user.df)
{
data(state.map, package="choroplethrMaps")
data(state.map, package="choroplethrMaps", envir=environment())
state.map$state = state.map$region
super$initialize(state.map, user.df)

Expand Down
6 changes: 3 additions & 3 deletions R/usa.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ USAChoropleth = R6Class("USAChoropleth",

render_state_outline = function(states)
{
data(state.map, package="choroplethrMaps")
data(state.regions, package="choroplethrMaps")
data(state.map, package="choroplethrMaps", envir=environment())
data(state.regions, package="choroplethrMaps", envir=environment())

stopifnot(states %in% state.regions$region)

Expand All @@ -103,7 +103,7 @@ USAChoropleth = R6Class("USAChoropleth",
# all maps of US states zoom at the unit of states.
set_zoom = function(zoom)
{
data(state.map, package="choroplethrMaps")
data(state.map, package="choroplethrMaps", envir=environment())
all_states = unique(state.map$region)

if (is.null(zoom))
Expand Down
2 changes: 1 addition & 1 deletion R/zip.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ZipMap = R6Class("CountyChoropleth",
super$initialize(zipcode, user.df)

# by default, show all states on the map
data(state.map, package="choroplethrMaps")
data(state.map, package="choroplethrMaps", envir=environment())
private$zoom = unique(state.map$region)
},

Expand Down
1 change: 1 addition & 0 deletions choroplethr.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ LaTeX: pdfLaTeX

BuildType: Package
PackageInstallArgs: --no-multiarch --with-keep.source
PackageCheckArgs: --as-cran

0 comments on commit af67994

Please sign in to comment.