[R] store levels in a string

Marc Schwartz (via MN) mschwartz at mn.rr.com
Tue Apr 18 21:12:36 CEST 2006


On Tue, 2006-04-18 at 20:53 +0200, Daniele Medri wrote:
> Il giorno mar, 18/04/2006 alle 11.29 -0500, Marc Schwartz (via MN):
> > > paste(levels(af), collapse = "")
> > [1] "ab"
> > 
> > See ?paste.
> 
> :) more simple: toString(levels(x))
> 
> Thanks,
> 
> Cheers
> --
> DM

Actually, you don't quite get the same result:

> toString(levels(af))
[1] "a, b"

Note the inclusion of the ', '.  

See the first line in toString.default() which is:

  string <- paste(x, collapse = ", ")

HTH,

Marc




More information about the R-help mailing list