Re: [R] unwanted coercion using apply

From: Jeroen Ooms <jeroenooms_at_gmail.com>
Date: Sun, 22 May 2011 12:22:01 -0700

>
> apply() operates on arrays and a data frame will be coerced to a matrix
> (which requires all elements to be of the same type). This is documented in
> ?apply.
>

Thanks, I was not aware of that. I implicitly assumed there would be a specific apply.data.frame.

> This may not be elegant, but why not just use a loop:
>

The thing is that were are going to use this operation on a (very) large scale in a production environment, on datasets for which nrow >> ncol. So I would like the most efficient solution and if possibly, avoid looping over the rows.

Thanks

Jeroen

        [[alternative HTML version deleted]]



R-help_at_r-project.org 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 Sun 22 May 2011 - 19:24:53 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 22 May 2011 - 19:50:09 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.

list of date sections of archive