DATA MINING
Desktop Survival Guide by Graham Williams |
|||||
Replace Indices By Names |
> city.name <- c("Munich", "Paris", "Tokyo", "London", "Boston") > X <- cbind(c(2, 5, 5), c(4, 1, 3)) > X [,1] [,2] [1,] 2 4 [2,] 5 1 [3,] 5 3 > matrix(city.name[X], ncol = 2) [,1] [,2] [1,] "Paris" "London" [2,] "Boston" "Munich" [3,] "Boston" "Tokyo" |