r - Assigning labels to values -


i have dataset numbers 1:70 correspond neighborhood name within city. data set so:

    date | area | count    04/16    1       12    04/16    1       1    05/16    2       3    06/16    3       10 

i have dataframe area number , corresponding area name.

number | name   1       franklin   2       state 

how can assign area number value corresponding name without having type out each number , name?

you can match

## data dat = read.table(text="   date  area  count    04/16    1       12    04/16    1       1    05/16    2       3    06/16    3       10", header=true, stringsasfactors=false)  areas = read.table(text="number  name   1       franklin   2       state", header=true, stringsasfactors=false)  areas$name[match(dat$area, areas$number)] [1] "franklin" "franklin" "state"    na   

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -