R data frame create a new variable which corresponds to one of the existing one
-
16-10-2019 - |
Question
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.
Solution
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with datascience.stackexchange