Hello R people, I have a "data.frame". Status variable has 3 values. 0->alive, 1->dead and 2->missed Status as a factor have correct levels. Levels and labels output as follows; levels(Adbf$status); labels(Adbf$status) [1] "0" "1" "2" [1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" [11] "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" [21] "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" [31] "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" [41] "41" "42" "43" "44" "45" "46" "47" "48" "49" "50" ........................................................................"644" Can i add value.labels to status variable? If yes how? Can i see these value.labels on results or graphics? Thanks. -- View this message in context: http://r.789695.n4.nabble.com/value-labels-tp3735947p3735947.html Sent from the R help mailing list archive at Nabble.com.
On 11.08.2011 16:10, zcatav wrote:> Hello R people, > > I have a "data.frame". Status variable has 3 values. 0->alive, 1->dead and > 2->missed > Status as a factor have correct levels. Levels and labels output as follows; > > levels(Adbf$status); labels(Adbf$status) > [1] "0" "1" "2" > [1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" > [11] "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" > [21] "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" > [31] "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" > [41] "41" "42" "43" "44" "45" "46" "47" "48" "49" "50" > > ........................................................................"644" > > Can i add value.labels to status variable? If yes how? Can i see these > value.labels on results or graphics?levels(Adbf$status) <- c("alive", "dead", "missed") Uwe Ligges> Thanks. > > -- > View this message in context: http://r.789695.n4.nabble.com/value-labels-tp3735947p3735947.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.
On 08/12/2011 12:10 AM, zcatav wrote:> Hello R people, > > I have a "data.frame". Status variable has 3 values. 0->alive, 1->dead and > 2->missed > Status as a factor have correct levels. Levels and labels output as follows; > > levels(Adbf$status); labels(Adbf$status) > [1] "0" "1" "2" > [1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" > [11] "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" > [21] "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" > [31] "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" > [41] "41" "42" "43" "44" "45" "46" "47" "48" "49" "50" > > ........................................................................"644" > > Can i add value.labels to status variable? If yes how? Can i see these > value.labels on results or graphics? >Hi zcatav, There is a convenience function in the prettyR package named "add.value.labels" that does just that. It is there mostly so that someone with data not converted from SPSS can make them look like data that has been converted from SPSS. I don't know whether the method used will work with functions from any other package, though. Jim
Hi, My data.frame as follows; a b c d 1 58009 2010-11-02 0 NA 2 114761 2011-07-28 1 2008-11-05 3 184440 2011-07-28 1 2009-12-08 4 189372 2011-07-28 0 NA 5 105286 NA 2 NA 6 186717 2011-07-28 0 NA 7 189106 2011-07-28 0 NA 8 127306 2011-07-28 0 NA 9 157342 2011-04-25 0 NA> library("prettyR") > add.value.labels(test2$c, "alive","dead","missed")Error in add.value.labels(test2$c, "alive", "dead", "missed") : unused argument(s) ("dead", "missed")> add.value.labels(test2$c, "alive")[1] 0 1 1 0 2 0 0 0 0 attr(,"value.labels") alive <NA> <NA> 0 1 2 This function allows only one label. How can add second and other labels? Thanks. -- View this message in context: http://r.789695.n4.nabble.com/value-labels-tp3735947p3738244.html Sent from the R help mailing list archive at Nabble.com.