[R] value.labels

zcatav zcatav at gmail.com
Fri Aug 12 19:40:24 CEST 2011


Jim Lemon wrote:
> 
> Hi Zeki,
> 
> fgh<-read.table("fgh.tab",header=TRUE,sep="\t")
> fgh$c<-add.value.labels(fgh$c,c("alive","dead","zombie"))
> fgh$c
> 
> Jim
> 

Thanks Jim,
This is what i want.

Result as follows;

> test2$c<-add.value.labels(test2$c,c("alive","dead","zombie"))
> test2$c
[1] 0 1 1 0 2 0 0 0 0
attr(,"value.labels")
 alive   dead zombie 
     0      1      2 
> table(test2$c)

0 1 2 
6 2 1 
> str(test2)
'data.frame':	9 obs. of  4 variables:
 $ a: int  58009 114761 184440 189372 105286 186717 189106 127306 157342
 $ b: Date, format: "2011-07-28" "2008-11-05" ...
 $ c: atomic  0 1 1 0 2 0 0 0 0
  ..- attr(*, "value.labels")= Named num  0 1 2
  .. ..- attr(*, "names")= chr  "alive" "dead" "zombie"
 $ d: Date, format: NA "2008-11-05" ...


--
View this message in context: http://r.789695.n4.nabble.com/value-labels-tp3735947p3740000.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list