[R] forcing apply() to return data frame
Thomas Lumley
tlumley at u.washington.edu
Fri Apr 21 16:37:45 CEST 2006
On Fri, 21 Apr 2006, Federico Calboli wrote:
> 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?
>
The conversion to a matrix happens on the way in to apply, not on the way
out, so no.
-thomas
Thomas Lumley Assoc. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle
More information about the R-help
mailing list