Bill, Alberto, Gabor,
Thank you for answering my question. Now I learned about outer() function.
That was a straightforward example.
But what if I had a matrix, where the last column was filled with
values first (again, a for loop), and the rest was filled by using a
double loop?
OVal -
:[EMAIL PROTECTED]
On Behalf Of Jonas Malmros
Sent: Wednesday, March 19, 2008 9:04 AM
To: r-help@r-project.org
Subject: [R] How to remove double loop?
Bill, Alberto, Gabor,
Thank you for answering my question. Now I learned about outer()
function.
That was a straightforward example.
But what if I had
Read the posting guide (the bit about reproducible code):
OVal - matrix(0, n+1, n+1)
for(i in 0:n){
+ OVal[i+1, n+1] - max(Val[i+1, n+1]-K, 0)
+ }
Error: object Val not found
for(i in seq(n,1, by=-1)){
+ for(j in 0:(i-1)){
+ OVal[j+1, i] - a*((1-p)*OVal[j+1, i+1]+p*OVal[j+2,
Jonas Malmros wrote:
But what if I had a matrix, where the last column was filled with
values first (again, a for loop), and the rest was filled by using a
double loop?
Killing one of those loops is quite simple. The other may be
harder.
OVal - matrix(0, n+1, n+1)
for(i in 0:n){
On Thu, 20 Mar 2008, Alberto Monteiro wrote:
Jonas Malmros wrote:
But what if I had a matrix, where the last column was filled with
values first (again, a for loop), and the rest was filled by using a
double loop?
Killing one of those loops is quite simple. The other may be
harder.
5 matches
Mail list logo