I downloaded data from Eurostat to R. In one column I have abbreviated country names, I found how to display full names. But I need to change these row names to show in a different language. I don't care about a specific function, I can do it manually, but how?
How to rename row names in data from Eurostat in R
110 views Asked by ozi At
2
There are 2 answers
0
On
You can set row names with rownames
d <- data.frame(x=1:3, y = letters[1:3])
rownames(d)
#[1] "1" "2" "3"
rownames(d) = c("the", "fox", "jumps")
rownames(d)
#[1] "the" "fox" "jumps"
Or you can add a new column to a data.frame like this
d$french <- c("le", "renard", "saute")
d
# x y french
#the 1 a le
#fox 2 b renard
#jumps 3 c saute
Even with another script
d$tajik <- c("рӯбоҳ", "ҷаҳиш", "мекунад")
May look weird because of the UTF-8 encoding
d
# x y french tajik
#the 1 a le <U+0440><U+04EF><U+0431><U+043E><U+04B3>
#fox 2 b renard <U+04B7><U+0430><U+04B3><U+0438><U+0448>
#jumps 3 c saute <U+043C><U+0435><U+043A><U+0443><U+043D><U+0430><U+0434>
But is good
d$tajik
#[1] "рӯбоҳ" "ҷаҳиш" "мекунад"
The
countrycode
package could help:Check out
?countrycode
and?codelist
for more encoding options.