-
From: David Winsemius [mailto:dwinsem...@comcast.net]
Sent: maandag 8 november 2010 15:04
To: Nick Sabbe
Cc: 'PLucas'; r-help@r-project.org
Subject: Re: [R] How to eliminate this for loop ?
On Nov 8, 2010, at 4:30 AM, Nick Sabbe wrote:
Whenever you use a recursion (that cannot be expressed
[mailto:r-help-boun...@r-
project.org] On Behalf Of Greg Snow
Sent: Monday, November 08, 2010 1:15 PM
To: PLucas; r-help@r-project.org
Subject: Re: [R] How to eliminate this for loop ?
If you are willing to shift the c vector by 1 and have 1 (the initial
value) as the start of c, then you can
Erich:
(Assuming this is correct), this is very nice. However, I just wanted
to point out that if you look at the code for Reduce, you'll find it's
implemented with for loops. So the OP's original version using a for
loop is likely to be faster (just as it's likely to be faster than my
actual
...@r-project.org [mailto:r-help-boun...@r-
project.org] On Behalf Of Greg Snow
Sent: Monday, November 08, 2010 1:15 PM
To: PLucas; r-help@r-project.org
Subject: Re: [R] How to eliminate this for loop ?
If you are willing to shift the c vector by 1 and have 1
(the initial
value
-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
project.org] On Behalf Of William Dunlap
Sent: Tuesday, November 09, 2010 10:07 AM
To: PLucas; r-help@r-project.org
Subject: Re: [R] How to eliminate this for loop ?
Note that for long vectors the OP's code would
go much
Hi, I would like to create a list recursively and eliminate my for loop :
a-c()
a[1] - 1; # initial value
for(i in 2:N) {
a[i]-a[i-1]*b - c[i-1] # b is a value, c is another vector
}
Is it possible ?
Thanks
--
View this message in context:
] How to eliminate this for loop ?
Hi, I would like to create a list recursively and eliminate my for loop :
a-c()
a[1] - 1; # initial value
for(i in 2:N) {
a[i]-a[i-1]*b - c[i-1] # b is a value, c is another vector
}
Is it possible ?
Thanks
--
View this message in context:
http://r
Hi:
?Recall
HTH,
Dennis
On Mon, Nov 8, 2010 at 1:25 AM, PLucas plucasplucasplu...@yopmail.comwrote:
Hi, I would like to create a list recursively and eliminate my for loop :
a-c()
a[1] - 1; # initial value
for(i in 2:N) {
a[i]-a[i-1]*b - c[i-1] # b is a value, c is another vector
653, 9000 Gent
ring: 09/264.59.36
-- Do Not Disapprove
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org
] On
Behalf Of PLucas
Sent: maandag 8 november 2010 10:26
To: r-help@r-project.org
Subject: [R] How to eliminate this for loop ?
Hi, I
-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On
Behalf Of PLucas
Sent: maandag 8 november 2010 10:26
To: r-help@r-project.org
Subject: [R] How to eliminate this for loop ?
Hi, I would like to create a list recursively and eliminate my for loop :
a-c()
a[1
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
project.org] On Behalf Of PLucas
Sent: Monday, November 08, 2010 2:26 AM
To: r-help@r-project.org
Subject: [R] How to eliminate this for loop ?
Hi, I would like to create a list recursively
Reduce(function(x1,x2)b*x1-x2,c,init=1,accum=TRUE)
might be what you are looking for.
This is not fully tested, so you should test it before
you want to use it.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do
12 matches
Mail list logo