[R] value.labels

Jim Lemon jim at bitwrit.com.au
Fri Aug 12 10:08:18 CEST 2011


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



More information about the R-help mailing list