[R] store levels in a string

Marc Schwartz (via MN) mschwartz at mn.rr.com
Tue Apr 18 18:00:02 CEST 2006


On Tue, 2006-04-18 at 17:52 +0200, Daniele Medri wrote:
> Dear R-users,
> 
> i need to store in a variable a string made from levels of a factor
> 
> e.g.
> 
> a<-("a","a","b","b")

The above should be:

a <- c("a","a","b","b")
     ^

> af<-factor(a)
> 
> mylevels<- ...a string with all the levels(af)
> 
> Thanks
> --
> DM

> mylevels <- levels(af)

> mylevels
[1] "a" "b"


See ?levels, which is listed in the "See Also" for ?factor.

HTH,

Marc Schwartz




More information about the R-help mailing list