Hi, Dear R- community, I am use the intToChar function to convert the integers to letters. But the output is mess. Can you guys give some suggestions? Thanks!> outcome.predict[1] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 7 4 4 4 4 4 4 4 4 [26] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 7 4 4 4 4 4 7 4 4 4 4 [51] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 [76] 4 4 4 4 7 4 4 4 4 4 4 4 7 4 4 4 4 4 4 4 4 4 7 4 4 [101] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 7 7 4 4 4 4 4 [126] 2 2 2 10 4 4 4 4 4 4 4 4 7 7 7 4 4 4 4 4 10 10 13 3 13 [151] 2 4 4 4 4 4 4 4 4 4 4 4 4 4 10 3 13 3 2 2 11 3 4 4 4 [176] 13 4 4 4 4 13 13 4 2 10 13 13 2 3 3 13 10 2 4 4 4 1 1 4 4 [201] 13 13 2 2 13 2 3 13 13 2 2 3 11 13 3 2 1 4 4 4 13 13 13 2 10 [226] 10 2 2 10 11 13 13 10 10 2 3 1 4 1 4 13 3 10 10 10 13 3 11 11 11 [251] 10 2 10 3 5 5 4 4 4 11 6 12 3 10 3 3 1 2 2 11 3 3 3 10 12 [276] 5 5 4 4 4 6 6 5 12 2 1 2 13 11 4 11 10 12 12 12 5 12 5 12 12 [301] 6 6 6 12 12 3 2 3 2 1 12 12 12 5 12 12 12 9 9 12 6 6 6 12 2 [326] 2 10 10 12 12 12 12 12 12 5 5 12 12 12 12 6 6 6 6 6 2 2 5 12 12 [351] 12 12 12 12 9 12 12 12 12 12 6 6 6 6 6 6 6 12 12 12 12 12 12 9 5 [376] 5 12 12 5 12 6 6 6 6 6 6 6 6 12 12 12 12 12 9 9 12 5 12 12 12 [401] 6 6 6 6 6 6 5 9 5 5 12 12 9 9 9 12 9 12 12 12 6 6 6 6 6 [426] 6 5 5 5 12 9 9 12 9 12 12 9 12 12 12 12 6 6 6 12 12 5 5 12 9 [451] 5 12 6 12 12 12 12 12 12 12 6 6 5 6 5 5 5 5 5 5 5 5 12 12 12 [476] 9 9 5 9 9 12 5 5 5 5 5 5 5 5 5 5 12 12 12 12 5 5 5 5 12 [501] 5 9 5 5 5 5 5 5 5 5 5 5 12 12 5 5 5 5 9 5 5 5 5 5 5 [526] 5 5 5 5 5 5 5 5 5 5 9 12 5 5 5 5 5 5 5 5 5 5 5 5 5 [551] 5 5 5 9 5 5 5 5 9 5 5 5 5 5 5 5 5 5 5 9 9 5 5 5 5 [576] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 9 5 9 5> outcome.label<-intToChar(outcome.predict) > outcome.label[1] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" [11] "\004" "\004" "\004" "\004" "\004" "\004" "\a" "\004" "\004" "\004" [21] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" [31] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a" [41] "\004" "\004" "\004" "\004" "\004" "\a" "\004" "\004" "\004" "\004" [51] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" [61] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" [71] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a" [81] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a" "\004" "\004" [91] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a" "\004" "\004" [101] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" [111] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a" "\a" [121] "\004" "\004" "\004" "\004" "\004" "\002" "\002" "\002" "\n" "\004" [131] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a" "\a" "\a" [141] "\004" "\004" "\004" "\004" "\004" "\n" "\n" "\r" "\003" "\r" [151] "\002" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" [161] "\004" "\004" "\004" "\004" "\n" "\003" "\r" "\003" "\002" "\002" [171] "\v" "\003" "\004" "\004" "\004" "\r" "\004" "\004" "\004" "\004" [181] "\r" "\r" "\004" "\002" "\n" "\r" "\r" "\002" "\003" "\003" [191] "\r" "\n" "\002" "\004" "\004" "\004" "\001" "\001" "\004" "\004" [201] "\r" "\r" "\002" "\002" "\r" "\002" "\003" "\r" "\r" "\002" [211] "\002" "\003" "\v" "\r" "\003" "\002" "\001" "\004" "\004" "\004" [221] "\r" "\r" "\r" "\002" "\n" "\n" "\002" "\002" "\n" "\v" [231] "\r" "\r" "\n" "\n" "\002" "\003" "\001" "\004" "\001" "\004" [241] "\r" "\003" "\n" "\n" "\n" "\r" "\003" "\v" "\v" "\v" [251] "\n" "\002" "\n" "\003" "\005" "\005" "\004" "\004" "\004" "\v" [261] "\006" "\f" "\003" "\n" "\003" "\003" "\001" "\002" "\002" "\v" [271] "\003" "\003" "\003" "\n" "\f" "\005" "\005" "\004" "\004" "\004" [281] "\006" "\006" "\005" "\f" "\002" "\001" "\002" "\r" "\v" "\004" [291] "\v" "\n" "\f" "\f" "\f" "\005" "\f" "\005" "\f" "\f" [301] "\006" "\006" "\006" "\f" "\f" "\003" "\002" "\003" "\002" "\001" [311] "\f" "\f" "\f" "\005" "\f" "\f" "\f" "\t" "\t" "\f" [321] "\006" "\006" "\006" "\f" "\002" "\002" "\n" "\n" "\f" "\f" [331] "\f" "\f" "\f" "\f" "\005" "\005" "\f" "\f" "\f" "\f" [341] "\006" "\006" "\006" "\006" "\006" "\002" "\002" "\005" "\f" "\f" [351] "\f" "\f" "\f" "\f" "\t" "\f" "\f" "\f" "\f" "\f" [361] "\006" "\006" "\006" "\006" "\006" "\006" "\006" "\f" "\f" "\f" [371] "\f" "\f" "\f" "\t" "\005" "\005" "\f" "\f" "\005" "\f" [381] "\006" "\006" "\006" "\006" "\006" "\006" "\006" "\006" "\f" "\f" [391] "\f" "\f" "\f" "\t" "\t" "\f" "\005" "\f" "\f" "\f" [401] "\006" "\006" "\006" "\006" "\006" "\006" "\005" "\t" "\005" "\005" [411] "\f" "\f" "\t" "\t" "\t" "\f" "\t" "\f" "\f" "\f" [421] "\006" "\006" "\006" "\006" "\006" "\006" "\005" "\005" "\005" "\f" [431] "\t" "\t" "\f" "\t" "\f" "\f" "\t" "\f" "\f" "\f" [441] "\f" "\006" "\006" "\006" "\f" "\f" "\005" "\005" "\f" "\t" [451] "\005" "\f" "\006" "\f" "\f" "\f" "\f" "\f" "\f" "\f" [461] "\006" "\006" "\005" "\006" "\005" "\005" "\005" "\005" "\005" "\005" [471] "\005" "\005" "\f" "\f" "\f" "\t" "\t" "\005" "\t" "\t" [481] "\f" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" [491] "\005" "\f" "\f" "\f" "\f" "\005" "\005" "\005" "\005" "\f" [501] "\005" "\t" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" [511] "\005" "\005" "\f" "\f" "\005" "\005" "\005" "\005" "\t" "\005" [521] "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" [531] "\005" "\005" "\005" "\005" "\005" "\t" "\f" "\005" "\005" "\005" [541] "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" [551] "\005" "\005" "\005" "\t" "\005" "\005" "\005" "\005" "\t" "\005" [561] "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\t" [571] "\t" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" [581] "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" [591] "\005" "\005" "\005" "\005" "\005" "\005" "\t" "\005" "\t" "\005" -- Sincerely, Changbin -- [[alternative HTML version deleted]]
Try this: LETTERS[outcome.predict] On Tue, Jun 1, 2010 at 5:43 PM, Changbin Du <changbind@gmail.com> wrote:> Hi, Dear R- community, > > I am use the intToChar function to convert the integers to letters. But the > output is mess. Can you guys give some suggestions? Thanks! > > > outcome.predict > [1] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 7 4 4 4 4 4 4 > 4 4 > [26] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 7 4 4 4 4 4 7 4 4 > 4 4 > [51] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 > 4 4 > [76] 4 4 4 4 7 4 4 4 4 4 4 4 7 4 4 4 4 4 4 4 4 4 7 > 4 4 > [101] 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 7 7 4 4 4 > 4 4 > [126] 2 2 2 10 4 4 4 4 4 4 4 4 7 7 7 4 4 4 4 4 10 10 13 > 3 13 > [151] 2 4 4 4 4 4 4 4 4 4 4 4 4 4 10 3 13 3 2 2 11 3 4 > 4 4 > [176] 13 4 4 4 4 13 13 4 2 10 13 13 2 3 3 13 10 2 4 4 4 1 1 > 4 4 > [201] 13 13 2 2 13 2 3 13 13 2 2 3 11 13 3 2 1 4 4 4 13 13 13 > 2 10 > [226] 10 2 2 10 11 13 13 10 10 2 3 1 4 1 4 13 3 10 10 10 13 3 11 > 11 11 > [251] 10 2 10 3 5 5 4 4 4 11 6 12 3 10 3 3 1 2 2 11 3 3 3 > 10 12 > [276] 5 5 4 4 4 6 6 5 12 2 1 2 13 11 4 11 10 12 12 12 5 12 5 > 12 12 > [301] 6 6 6 12 12 3 2 3 2 1 12 12 12 5 12 12 12 9 9 12 6 6 6 > 12 2 > [326] 2 10 10 12 12 12 12 12 12 5 5 12 12 12 12 6 6 6 6 6 2 2 5 > 12 12 > [351] 12 12 12 12 9 12 12 12 12 12 6 6 6 6 6 6 6 12 12 12 12 12 12 > 9 5 > [376] 5 12 12 5 12 6 6 6 6 6 6 6 6 12 12 12 12 12 9 9 12 5 12 > 12 12 > [401] 6 6 6 6 6 6 5 9 5 5 12 12 9 9 9 12 9 12 12 12 6 6 6 > 6 6 > [426] 6 5 5 5 12 9 9 12 9 12 12 9 12 12 12 12 6 6 6 12 12 5 5 > 12 9 > [451] 5 12 6 12 12 12 12 12 12 12 6 6 5 6 5 5 5 5 5 5 5 5 12 > 12 12 > [476] 9 9 5 9 9 12 5 5 5 5 5 5 5 5 5 5 12 12 12 12 5 5 5 > 5 12 > [501] 5 9 5 5 5 5 5 5 5 5 5 5 12 12 5 5 5 5 9 5 5 5 5 > 5 5 > [526] 5 5 5 5 5 5 5 5 5 5 9 12 5 5 5 5 5 5 5 5 5 5 5 > 5 5 > [551] 5 5 5 9 5 5 5 5 9 5 5 5 5 5 5 5 5 5 5 9 9 5 5 > 5 5 > [576] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 9 5 > 9 5 > > outcome.label<-intToChar(outcome.predict) > > outcome.label > [1] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" > [11] "\004" "\004" "\004" "\004" "\004" "\004" "\a" "\004" "\004" "\004" > [21] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" > [31] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a" > [41] "\004" "\004" "\004" "\004" "\004" "\a" "\004" "\004" "\004" "\004" > [51] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" > [61] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" > [71] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a" > [81] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a" "\004" "\004" > [91] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a" "\004" "\004" > [101] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" > [111] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a" "\a" > [121] "\004" "\004" "\004" "\004" "\004" "\002" "\002" "\002" "\n" "\004" > [131] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a" "\a" "\a" > [141] "\004" "\004" "\004" "\004" "\004" "\n" "\n" "\r" "\003" "\r" > [151] "\002" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" > [161] "\004" "\004" "\004" "\004" "\n" "\003" "\r" "\003" "\002" "\002" > [171] "\v" "\003" "\004" "\004" "\004" "\r" "\004" "\004" "\004" "\004" > [181] "\r" "\r" "\004" "\002" "\n" "\r" "\r" "\002" "\003" "\003" > [191] "\r" "\n" "\002" "\004" "\004" "\004" "\001" "\001" "\004" "\004" > [201] "\r" "\r" "\002" "\002" "\r" "\002" "\003" "\r" "\r" "\002" > [211] "\002" "\003" "\v" "\r" "\003" "\002" "\001" "\004" "\004" "\004" > [221] "\r" "\r" "\r" "\002" "\n" "\n" "\002" "\002" "\n" "\v" > [231] "\r" "\r" "\n" "\n" "\002" "\003" "\001" "\004" "\001" "\004" > [241] "\r" "\003" "\n" "\n" "\n" "\r" "\003" "\v" "\v" "\v" > [251] "\n" "\002" "\n" "\003" "\005" "\005" "\004" "\004" "\004" "\v" > [261] "\006" "\f" "\003" "\n" "\003" "\003" "\001" "\002" "\002" "\v" > [271] "\003" "\003" "\003" "\n" "\f" "\005" "\005" "\004" "\004" "\004" > [281] "\006" "\006" "\005" "\f" "\002" "\001" "\002" "\r" "\v" "\004" > [291] "\v" "\n" "\f" "\f" "\f" "\005" "\f" "\005" "\f" "\f" > [301] "\006" "\006" "\006" "\f" "\f" "\003" "\002" "\003" "\002" "\001" > [311] "\f" "\f" "\f" "\005" "\f" "\f" "\f" "\t" "\t" "\f" > [321] "\006" "\006" "\006" "\f" "\002" "\002" "\n" "\n" "\f" "\f" > [331] "\f" "\f" "\f" "\f" "\005" "\005" "\f" "\f" "\f" "\f" > [341] "\006" "\006" "\006" "\006" "\006" "\002" "\002" "\005" "\f" "\f" > [351] "\f" "\f" "\f" "\f" "\t" "\f" "\f" "\f" "\f" "\f" > [361] "\006" "\006" "\006" "\006" "\006" "\006" "\006" "\f" "\f" "\f" > [371] "\f" "\f" "\f" "\t" "\005" "\005" "\f" "\f" "\005" "\f" > [381] "\006" "\006" "\006" "\006" "\006" "\006" "\006" "\006" "\f" "\f" > [391] "\f" "\f" "\f" "\t" "\t" "\f" "\005" "\f" "\f" "\f" > [401] "\006" "\006" "\006" "\006" "\006" "\006" "\005" "\t" "\005" "\005" > [411] "\f" "\f" "\t" "\t" "\t" "\f" "\t" "\f" "\f" "\f" > [421] "\006" "\006" "\006" "\006" "\006" "\006" "\005" "\005" "\005" "\f" > [431] "\t" "\t" "\f" "\t" "\f" "\f" "\t" "\f" "\f" "\f" > [441] "\f" "\006" "\006" "\006" "\f" "\f" "\005" "\005" "\f" "\t" > [451] "\005" "\f" "\006" "\f" "\f" "\f" "\f" "\f" "\f" "\f" > [461] "\006" "\006" "\005" "\006" "\005" "\005" "\005" "\005" "\005" "\005" > [471] "\005" "\005" "\f" "\f" "\f" "\t" "\t" "\005" "\t" "\t" > [481] "\f" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" > [491] "\005" "\f" "\f" "\f" "\f" "\005" "\005" "\005" "\005" "\f" > [501] "\005" "\t" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" > [511] "\005" "\005" "\f" "\f" "\005" "\005" "\005" "\005" "\t" "\005" > [521] "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" > [531] "\005" "\005" "\005" "\005" "\005" "\t" "\f" "\005" "\005" "\005" > [541] "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" > [551] "\005" "\005" "\005" "\t" "\005" "\005" "\005" "\005" "\t" "\005" > [561] "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\t" > [571] "\t" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" > [581] "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" "\005" > [591] "\005" "\005" "\005" "\005" "\005" "\005" "\t" "\005" "\t" "\005" > > -- > Sincerely, > Changbin > -- > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
That isn't really enough information to answer your question, since you don't tell us where intToChar comes from or what you are trying to do, but here are a couple of possibilities:> ?intToCharNo documentation for 'intToChar' in specified packages and libraries: you could try '??intToChar'> testdata <- sample(1:6, 10, replace=TRUE) > testdata[1] 5 3 2 5 6 3 4 5 4 4> as.character(testdata)[1] "5" "3" "2" "5" "6" "3" "4" "5" "4" "4"> letters[testdata][1] "e" "c" "b" "e" "f" "c" "d" "e" "d" "d" Sarah On Tue, Jun 1, 2010 at 4:43 PM, Changbin Du <changbind at gmail.com> wrote:> Hi, Dear R- community, > > I am use the intToChar function to convert the integers to letters. But the > output is mess. Can you guys give some suggestions? ? Thanks! > >> outcome.predict > ?[1] ?4 ?4 ?4 ?4 ?4 ?4 ?4 ?4 ?4 ?4 ?4 ?4 ?4 ?4 ?4 ?4 ?7 ?4 ?4 ?4 ?4 ?4 ?4 > 4 ?4 > ?[26] ?4 ?4 ?4 ?4 ?4 ?4 ?4 ?4 ?4 ?4 ?4 ?4 ?4 ?4 ?7 ?4 ?4 ?4 ?4 ?4 ?7 ?4 ?4 > 4 ?4 >> outcome.label<-intToChar(outcome.predict) >> outcome.label > ?[1] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" > ?[11] "\004" "\004" "\004" "\004" "\004" "\004" "\a" ? "\004" "\004" "\004" > ?[21] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" > ?[31] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a" > -- > Sincerely, > Changbin > ---- Sarah Goslee http://www.functionaldiversity.org
Changbin Du wrote:> Hi, Dear R- community, > > I am use the intToChar function to convert the integers to letters. But the > output is mess. Can you guys give some suggestions? Thanks! >I suggest you tell us what you were expecting to happen, that is, what do you actually want? It looks like it's doing something reasonable based in its name, but I can't be sure since you don't say what package intToChar is located in.