[R] forcing apply() to return data frame

Fredrik Karlsson dargosch at gmail.com
Fri Apr 21 17:39:27 CEST 2006


Hi,

There is a frameApply fynction in the library gdata from the gregmisc package.
The manual says it is like the function 'by', but returns a data.frame.

Maybe this is something for you?

/Fredrik



2006/4/21, Federico Calboli <f.calboli at imperial.ac.uk>:
> Hi All,
>
> I am (almost) successfully using apply() to apply a function recursively
> on a data matrix. The function is question is as.genotype() from the
> library 'genetics'
>
> apply(subset(chr1, names$breed == 'lab'),2,as.genotype,sep ="")
>
> Unfortuantely apply puts it's results into a matrix object rather than a
> data frame, tranforming my factors into numerics and making the results
> useless.
>
> Is there a way of forcing apply() to return a data frame rather than a
> matrix?
>
> Cheers,
>
> Federico
>
>
> --
> Federico C. F. Calboli
> Department of Epidemiology and Public Health
> Imperial College, St Mary's Campus
> Norfolk Place, London W2 1PG
>
> Tel  +44 (0)20 7594 1602     Fax (+44) 020 7594 3193
>
> f.calboli [.a.t] imperial.ac.uk
> f.calboli [.a.t] gmail.com
>
> ______________________________________________
> 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