Closed droach7 closed 2 years ago
Yes, I believe this has to do with the state code for the city you chose. You have a state that starts with a "06". Anytime you are having an issue with your data or tool you're using for analysis a number (here it is R, but this comes up anywhere) starting with a "0" is a red flag. You need to make the data numeric.
But before we move on I also want to point out the use of "msp". This is the used in the dataset for the location Minneapolis-St Paul. For your location I recommend changing this default to something that makes sense for your specific code.
To try to fix this error let's use the following code: msp.pop$GEOID <- as.numeric(msp.pop$GEOID)
and place it here: can merge an sf object and data.frame msp.pop$GEOID <- as.numeric(msp.pop$GEOID) msp <- merge( msp.pop, census.dat, by.x="GEOID", by.y="tractid" )
Now run it and see if it works.
@JasonSills
Sweet! Yes, that worked. I knew naming variables beginning with a number was problematic, but I guess I hadn't realized that using any numerical data starting with a 0 was problematic. Thanks for the help!
And yes, I know msp was used in the example for Minneapolis-St. Paul. I typically like to use the same names for variables while I run through the code and try to replicate it for my own chosen city, that way I know it is less likely to be a spelling mistake. Then in the end I go back and change the variable name to match.
resolved
@u12345 , @JasonSills
For Step 4 I keep getting this error message,
Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 'addAttrToGeom': subscript out of bounds
, after running this line of codemsp.sp <- as_Spatial( msp )
.I have selected Sacramento, CA as my MSA to explore. As this does not cross multiple states, I only needed one Census API call and therefore didn't need to bind map data from each state into 'msp.pop'. All my other data up to that point has been fine and is included below in one chunk for ease of viewing, however in my lab it is chunked out.
Can you please help me figure out why I keep getting this error code?