0

I am trying to make a heat map of the US with a very large data set and I am getting this error.

Error: cannot allocate vector of size 140.7 Mb

I know my data set might be to big, I am looking for options to keep the integrity of my data and still make my heat map.

This is what iv done so far.

ditch_the_axes <- theme(
  axis.text = element_blank(),
  axis.line = element_blank(),
  axis.ticks = element_blank(),
  panel.border = element_blank(),
  panel.grid = element_blank(),
  axis.title = element_blank()
)


MapKickstarter %>% ggplot( mapping = aes(x = long, y = lat, group = group)) + 
  geom_polygon( aes(fill = sqrt(pledgedUSD)), color = "white") +
  geom_polygon(color = "black", fill = NA) +
  theme_bw() + ditch_the_axes +
  scale_fill_gradientn(colours = rev(rainbow(7)))

I used the maps package to get the polyogons of the US states and then merged with a data set of 97000 observations. This then gave me a data set of 36 million observations. This could could be the root of my problems but im wanted both polygon data and my other data set.

Polygon data set using maps package:

states <- map_data('state')

Merging my data set:

MapKickstarter <- inner_join(MapKickstarter,states, by = "State")
Clinton Woods
  • 249
  • 1
  • 2
  • 11
  • 2
    Consider that a map of the US with filled polygons based on some value will give you at most 50 data points. Perhaps you want to be summarizing your kickstarter data to one value per state before plotting? – Brian Nov 18 '17 at 20:23
  • I like this idea ill try it. Thanks for the giving the outside perspective. – Clinton Woods Nov 19 '17 at 00:57
  • If you're trying to show something more complex, like distribution of `pledgedUSD` or a timeseries, consider an abstraction over the states, such as https://cran.r-project.org/package=geofacet – Brian Nov 19 '17 at 16:20

0 Answers0