Currently this is what I get. "community_area_clean" is the new variable that I added by extracting a variable that lists all the communities from a data frame. "CommArea_Name" is the original "unclean" variable. But I find that the names in "community_area_clean" do not correspond to the names in "CommArea_Name". How can I fix it? Thanks.
1 Answer
If my assumptions about CommArea_Num
are correct, then:
data$community_area_clean = data$community_area_clean[data$CommAreaNum]
should remap that column. Note that the AREA_KM
fields will remain in the order currently shown.
-
$\begingroup$ Oh yes! I think you are right! But how can I change the order of AREA_KM so that it corresponds to other variables? $\endgroup$– user27822Jan 10, 2017 at 17:20
-
$\begingroup$ Do the same thing with
AREA_KM
instead. Note you should end up with the area of ROGERS PARK as 2.700750 units. If this is actually the area of KENWOOD then some more fiddling required... $\endgroup$ Jan 10, 2017 at 18:20
CommArea_Num
column mean anything? It looks like LINCOLN SQUARE has a 4 there and is the fourth in the community_area_clean column. Same for ROGERS PARK, which has a 1 and is first in the other column. Is that true all the way through? Does the AREA_KM correspond to the CommArea_Name place or the community_area_clean place in each row/ $\endgroup$