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:> Dear all I want to convert a apply to lapply. The reason for that is that
there is a function mclappy that uses exact the same format as the lapply
function.
>
> My code looks like that
>
> mean_power_per_tip <- function(data) {
> ??????? return((apply(data[,],2,MeanTip)));
> }
>
> where data is a [m,n] matrix.
>
> I would like to thank you in advance for your help
>
> B.R
> Alex
>
> ? ? ? ?[[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.
>
>
--
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, ATS Statistical Consulting Group
University of California, Los Angeles
https://joshuawiley.com/