I have a huge dataframe df containing Numbers in the column "a" I also have a dataFrame name that contains the names corresponding to these numbers.
df:
a b c name:
1 val1 val2 1 cat
1 val1 val2 2 dog
2 val1 val2 3 rabbit
3 val1 val2
3 val1 val2
3 val1 val2
Now I want to replace the numbers with the names. The new dataFrame should look like this:
df:
a b c
cat val1 val2
cat val1 val2
dog val1 val2
rabbit val1 val2
rabbit val1 val2
rabbit val1 val2
I realized this like that. It works but I am not content, because I hardCode the names ...
df$a<-replace(df$a, df$a==1, "cat" )
df$a<-replace(df$a, df$a==2, "dog" )
df$a<-replace(df$a, df$a==3, "rabbit" )
How can I get the new values out of my dataframe name ?
Thank you!
dplyror ``data.table` for example.