set.seed(0)
data=data.frame("V1"=sample(1:10,size=4,rep=T),
"V2"=sample(1:10,size=4,rep=T),
"V3"=sample(1:10,size=4,rep=T),
"V4"=sample(1:10,size=4,rep=T))
names = data.frame("vars"=c("V1", "V2", "V3", "V4"),
"labels"=c("whale","toast","cheese","cow"))
want=data.frame("whale"=sample(1:10,size=4,rep=T),
"toast"=sample(1:10,size=4,rep=T),
"cheese"=sample(1:10,size=4,rep=T),
"cow"=sample(1:10,size=4,rep=T))
I have data, "data" and a dataframe "names" that contains the col names of "data" and the variable labels.
I want to create new data "want" which replaces the variable names in "data" with the variable labels in "names" Note however the actual values are different because I do not know how to ensure the same sampled values!