I have data like this
col1
33
924
33
12
924
and a dataframe like this
col1 col2
12 "London"
33 "Paris"
924 "Singapore"
How do I label the first dataframe based on the columns in the second dataframe using r's labelled?
I know that using val_labels() I can apply a value label to values in a column using:
val_labels(df$col1) <- c(London = 12, Paris = 33, Singapore = 924)
But I have 1000 different values and need an approach that allows me to use a dataframe to do it.
You can try this, though there are likely more elegant solutions: