1
$\begingroup$

enter image description here

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.

$\endgroup$
1
  • $\begingroup$ Does that 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$ – Spacedman Jan 10 '17 at 16:57
0
$\begingroup$

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.

$\endgroup$
2
  • $\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$ – user27822 Jan 10 '17 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$ – Spacedman Jan 10 '17 at 18:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy