[R] R lappy, sapply or mapply question

Frank Schwidom schwidom at gmx.net
Sat Oct 10 16:10:40 CEST 2015


correction:

On 2015-10-10 16:08:39, Frank Schwidom wrote:
> On 2015-10-09 20:15:16, liqunhan--- via R-help wrote:
> 
> > for (k in 1 : 50000) {
> >   xlist <- list(x5 = dailyrecord$a[k], x6 = dailyrecord$e[k], x7 = dailyrecord$f[k])
> >   result_forloop[k] <- fun3(list1, list2, xlist)
> > }
> 
> result_forloop <- lapply( 1 : 50000, function( k) {
> 
>  tmpRow <- dailyrecord[ k, ]
> 
>  xlist <- with( tmpRow, list( x5= a, x6= e, x7= f))
> 
>  fun3(list1, list2, xlist)
> 
> })
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>



More information about the R-help mailing list