[R] lapply (and friends) with data.frames are slow

2013-01-05 Thread Kevin Ushey
Hey guys, I noticed something curious in the lapply call. I'll copy+paste the function call here because it's short enough: lapply - function (X, FUN, ...) { FUN - match.fun(FUN) if (!is.vector(X) || is.object(X)) X - as.list(X) .Internal(lapply(X, FUN)) } Notice that lapply

Re: [R] lapply (and friends) with data.frames are slow

2013-01-05 Thread R. Michael Weylandt
On Sat, Jan 5, 2013 at 7:38 PM, Kevin Ushey kevinus...@gmail.com wrote: Hey guys, I noticed something curious in the lapply call. I'll copy+paste the function call here because it's short enough: lapply - function (X, FUN, ...) { FUN - match.fun(FUN) if (!is.vector(X) ||

Re: [R] lapply (and friends) with data.frames are slow

2013-01-05 Thread David Winsemius
On Jan 5, 2013, at 11:38 AM, Kevin Ushey wrote: Hey guys, I noticed something curious in the lapply call. I'll copy+paste the function call here because it's short enough: lapply - function (X, FUN, ...) { FUN - match.fun(FUN) if (!is.vector(X) || is.object(X)) X - as.list(X)

Re: [R] lapply (and friends) with data.frames are slow

2013-01-05 Thread Kevin Ushey
Hi David, Yes, it is - although the SO question was more directed at figuring out why sapply seemed slower, the question to R-help is more nuanced in is this coercion really necessary for data.frames?, and I figured it might take some more knowledge of R internals / the difference between lists