Hi,
I'm trying to get better at things like lapply but it still stumps
me. I have a function I've written, tested and debugged using
individual calls to the function, ala:
ResultList5 = DoAvgCalcs(IndexData, Lookback=5,
SampleSize=TestSamples , Iterations=TestIterations )
ResultList8 =
Mark -
The l in lapply refers to that fact that it will *return*
a list, not that it wants a list for input. You could input
a list, but then each element of the list would be one of the
values you wanted processed. So I think you want
x = seq(5:20)
ResultList = lapply(x, DoAvgCalcs,
Phil,
Thanks for the reply. Your suggestion is actually the one I started
with (assuming I'm understanding you) but I didn't seem to even get
down into my function, or the error message is from other place within
my function that I haven't discovered yet:
x = seq(5:20)
ResultList = lapply(x,
Change the order of the parameters in your function so that Lookback
is the first one. The first parameter of the lapply is what is passed
to the function as its first parameter. Now just have
ResultList - lapply(x, DoAvgCalcs, IndexData=IndexData,
SampleSize=TestSamples,
Thanks Jim. That did the trick.
I had wondered in passing about that as all the examples in the
?lapply page were pretty simple and each time it was the first
argument. However I didn't read that this was a requirement so I
didn't go there. Is this really stated and I just cannot see it or
...
Bert Gunter
Genentech Nonclinical Statistics
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Mark Knecht
Sent: Friday, September 18, 2009 11:55 AM
To: jim holtman
Cc: r-help; Phil Spector
Subject: Re: [R] lapply - value changes
Statistics
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Mark Knecht
Sent: Friday, September 18, 2009 11:55 AM
To: jim holtman
Cc: r-help; Phil Spector
Subject: Re: [R] lapply - value changes as parameters to function
7 matches
Mail list logo