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

From: Weiwei Shi <helprhelp_at_gmail.com>
Date: Wed 04 Oct 2006 - 17:18:06 GMT

thanks, Andy and Jacques.
I forgot to convert the result from lapply to data.frame when I tried lapply last time, :)
I should have done this
data.frame(lapply(x, factor))

On 10/4/06, Liaw, Andy <andy_liaw@merck.com> wrote:
> 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 attachment...{{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 03:21:44 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.