Re: [R-sig-Geo] [Help] Error in spChFIDs(SP, x) : lengths differ

2015-09-05 Thread Robert J. Hijmans
There is no need to 'make a copy of the attribute table' of the sp object. Instead, you should be able to do: library(sp) # From https://www.census.gov/geo/maps-data/data/cbf/cbf_state.html states <- readOGR(dsn = "./cb_2014_us_state_5m.shp", layer = "cb_2014_us_state_5m") states <-

Re: [R-sig-Geo] [Help] Error in spChFIDs(SP, x) : lengths differ

2015-09-04 Thread Ignacio Martinez
Thanks Edzer. I think I understand the problem better now (this is all very new to me). Is there a solution so I can generate the map with my data? Thanks again! On Fri, Sep 4, 2015 at 9:51 AM Edzer Pebesma wrote: > > > On 09/04/2015 03:29 PM, Ignacio Martinez

[R-sig-Geo] [Help] Error in spChFIDs(SP, x) : lengths differ

2015-09-04 Thread Ignacio Martinez
I'm trying to create a map using leaflet. I'm basically following this but my data is a bit different this time around. Additionally, I'm using dplyr instead of data.table. This is the code i'm trying to run: counts <- structure(

Re: [R-sig-Geo] [Help] Error in spChFIDs(SP, x) : lengths differ

2015-09-04 Thread Edzer Pebesma
On 09/04/2015 03:29 PM, Ignacio Martinez wrote: > I'm trying to create a map using leaflet. I'm basically following this > but my data is a bit > different this time around. Additionally, I'm using dplyr instead of > data.table. > > This is the

Re: [R-sig-Geo] [Help] Error in spChFIDs(SP, x) : lengths differ

2015-09-04 Thread Ignacio Martinez
I'm not sure what I'm missing. This is not working (same error): counts <- structure( list( STUSPS = c( "CA", "NC", "TX", "FL", "VA", "OH", "NY", "GA", "IL", "WA", "CO", "AZ", "MD", "LA", "SC", "KS", "DC", "TN", "MA", "MI", "MN",

Re: [R-sig-Geo] [Help] Error in spChFIDs(SP, x) : lengths differ

2015-09-04 Thread Ignacio Martinez
This works :-) : library(dplyr) library(leaflet) library(rgdal) library(sp) states <- rgdal::readOGR(dsn = "./cb_2014_us_state_5m.shp", layer = "cb_2014_us_state_5m", verbose = FALSE) statesnames <- states@data %>% mutate(STUSPS =

Re: [R-sig-Geo] [Help] Error in spChFIDs(SP, x) : lengths differ

2015-09-04 Thread Edzer Pebesma
On 09/04/2015 03:53 PM, Ignacio Martinez wrote: > Thanks Edzer. I think I understand the problem better now (this is all > very new to me). Is there a solution so I can generate the map with my data? > The STUSPS fields of counts and states match, but you seem to filter the attribute table after