Re: [R] how to convert all columns of a data frame into factors

From: Liaw, Andy <andy_liaw_at_merck.com>
Date: Wed 04 Oct 2006 - 15:49:31 GMT


Alternatively:

x[] <- lapply(x, factor)

Recall that a data frame is a list, so lapply() is a natural choice.

Andy

From: Gabor Grothendieck
>
> Try this:
>
> replace(BOD, TRUE, lapply(BOD, factor))
>
>
> On 10/4/06, Weiwei Shi <helprhelp@gmail.com> wrote:
> > Hi,
> >
> > I use "apply"
> > apply(x, 2, factor)
> >
> > but it does not work. please help. thanks.
> >
> > --
> > Weiwei Shi, Ph.D
> > Research Scientist
> > GeneGO, Inc.
> >
> > "Did you always know?"
> > "No, I did not. But I believed..."
> > ---Matrix III
> >
> > ______________________________________________
> > R-help@stat.math.ethz.ch 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.
> >
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>
>
>



Notice: This e-mail message, together with any attachments,...{{dropped}}

R-help@stat.math.ethz.ch 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. Received on Thu Oct 05 01:59:33 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 04 Oct 2006 - 17:30:08 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.