看板 R_Language 關於我們 聯絡資訊
我現在造一個data frame z x <- c(3,2,3,2,3,1,1,2) y <- 1:8 z <- as.data.frame(cbind(x,y)) 對這個data frame z 請問有沒有不用loop的方法把column x裡面的 1 2 3 替換成 'a' 'b' 'c' 呢? 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.24.180.180 ※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1427973019.A.1CA.html
ntme: z$x[z$x == 1] = "a" 04/02 19:27
感謝 分享一下剛才問到的 z$x <- letters[z$x] ※ 編輯: alasa15 (114.24.180.180), 04/02/2015 19:39:35
ty854697: try mapvalues() or revalue() 04/02 22:27
ty854697: http://ppt.cc/ZNeJ 04/02 22:28