[R] using lapply

From: Kushan Thakkar <kthakk4_at_gmail.com>
Date: Wed, 09 Mar 2011 20:46:26 -0600

I have a function with the follow signare:

apply.strategy(instr, strat)

where instr and strat are both objects of classes instrument and strategy respectively.

I want to apply this function to a list that holds objects of the class instrument.

Currently I am doing this by explicit looping:

for(i in length(instr.list) ) {

    apply.strategy(instr.list[[i]], my.strat) }

Is it possible to achieve this task by using one of the built in functions in R? I have looked at lapply but can't quite figure out how to pass the arguments.

What would be the performance implications of one method vs. the other?


        [[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 Thu 10 Mar 2011 - 06:40:40 GMT

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 Thu 10 Mar 2011 - 09:50:19 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