[R] concatenating factor from list

Gabor Grothendieck ggrothendieck at gmail.com
Thu Mar 16 01:28:22 CET 2006


Since all components of cutYield have the same levels, one
could do this to ensure that all levels are represented:

factor(unlist(lapply(cutYield, as.character)), levels = levels(cutYield[[1]]))


On 3/15/06, Sebastian Luque <spluque at gmail.com> wrote:
> "Gabor Grothendieck" <ggrothendieck at gmail.com> wrote:
>
> > Is this ok or is it what you are trying to avoid:
>
> > factor(unlist(lapply(cutYield, as.character)))
>
> Thank you Gabor.  The problem with that is what if some levels do not
> appear in any member of cutYield?  In that case, the factor created above
> would contain fewer levels than those present in every member of cutYield.
>
> Cheers,
>
> --
> Sebastian P. Luque
>
> ______________________________________________
> R-help at 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
>




More information about the R-help mailing list