Skip to content
Prev 273889 / 398506 Next

convert apply to lappy

Hi Alex,

If "data" is a matrix, probably the easiest option would be:

tips <- as.data.frame(data)

mclapply(tips, foo)

By the way, I would recommend not using 'data' (which is also a
function) as the name of the object storing your data.  If your data
set has many columns and performance is an issue I might convert it to
a list instead of a data frame.  Note that if you wanted the
equivalent of apply(tips, 1, foo), you could transpose your matrix
first:  as.data.frame(t(data)).  lapply works on columns of a data
frame because each column is basically an element of a list (list
apply).

Cheers,

Josh
On Sun, Oct 9, 2011 at 8:47 AM, Alaios <alaios at yahoo.com> wrote: