Hi,
Sometimes the easiest things seem more complex that they should. I am looking to rename column values, not labels.
My data is like this
sample1 <- matrix(c("US.","EU.","JA.","US.","EU.","JA."),ncol=1,byrow=TRUE)
colnames(sample1) <- c("Country")
rownames(sample1) <- c("A","B","C","D", "E","F")
sample1 <- as.table(sample1)
sample1
Country
A US.
B EU.
C JA.
D US.
E EU.
F JA.
and I want to rename the country acronyms to be like this
sample2 <- matrix(c("USA","EUR","JAP","USA","EUR","JAP"),ncol=1,byrow=TRUE)
colnames(sample2) <- c("Country")
rownames(sample2) <- c("A","B","C","D", "E","F")
sample2 <- as.table(sample2)
sample2
Country
A USA
B EUR
C JAP
D USA
E EUR
F JAP
I have tried the below methods with no success:
rename.values(x, fish="newfish")
and
sample1$Country[sample1$Country == "US."] <-"USA"
In my real data, the format is factor, and I have also tried converting to character to rename.
Appreciate any help.
Thanks,
Ben