[R] Change column/row-name

Jörg Reuter joerg at reuter.at
Fri Oct 21 07:57:12 CEST 2011


Hi,
I am very happy. My problems are solved without one little thing:

(Iske <- matrix(c(1, 1, 1, 2, 2, 2, 1, 1, 1, 5, 1, 2, 2, 2, 1, 1, 1,
4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 4, 4, 4, 4, 4, 4, 2,
2, 2, 2, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 2), ncol = 5)) #My Matrix

Iske<- Iske+33 #I want see the letters

(Iske.char<-apply(Iske, 1, function(x) rawToChar(as.raw(x)))) #Numbers to Char
LD <- function(s1, s2){
    require(vwr)
    s1 = as.character(s1)
    s2 = as.character(s2)
    t(sapply(s1, levenshtein.distance, s2))
}
Iske.levens<-(LD(Iske.char,Iske.char)) #Calculate the Levenshtein-Distanz

The result:
!"#$% !"#$% !"#$% "!#$% ....
!"#$%     0     0     0
!"#$%     0     0     0
!"#$%     0     0     0
.
.
.
It is all beautiful. But is there a simple way to change the
column/row-name to the original from the Matrix Iske?

Thanks a lot for the help yesterday. It was a big step in my life :-)



More information about the R-help mailing list