DS4PS / cpp-529-spr-2020

Course shell for CPP 529 Data Practicum on Community Analytics for Spring 2020.
http://ds4ps.org/cpp-529-spr-2020
1 stars 1 forks source link

Lab04 - sf package #9

Open ecking opened 4 years ago

ecking commented 4 years ago

I know, second question of the night. But what does "Error in st_cast_sfc_default(x) : list item(s) not of class sfg" mean?

When I put in msp.sp <- as_Spatial( msp ) I get this message. I'm googling it and trying out different things. But even the help documentation I'm not quite understanding.

AntJam-Howell commented 4 years ago

@ecking can you attach your .rmd file for me to take a look.

AntJam-Howell commented 4 years ago

@ecking Just went through and figured out that the problem actually takes place on line 149 of you .RMD file when you merge the 2 datasets together

msp <- merge( msp.pop, census.dat, by.x="GEOID", by.y="tractid" )

For some reason, the merge brings back an empty dataset despite the tractid and GEOID number matching.

When I converted the matching variable in each dataset to be numeric instead of character, and merged, the problem was solved. You can convert the variables to numeric as shown below, and then re-run the merge after.

 census.dat$tractid<-as.numeric(census.dat$tractid)
 msp.pop$GEOID<-as.numeric(msp.pop$GEOID)
ecking commented 4 years ago

Thanks @Anthony-Howell-PhD, I never would have gotten that...

I'm running the code now and I hit the last section of code under Identifying "Neighborhood Clusters" -- Build the charts to compare census characteristics across the groups. and there is an a reference to object data.dictionary here that is not being found.

How should I go about resolving that? I do see that there is code at the bottom of the page for data.dictionary but seems out of order.

ecking commented 4 years ago

looks like adding that chunk of code before that last chunk worked.

Thanks