[R] creating a reverse geometric sequence

2010-05-23 Thread Erik Iverson
Hello, Can anyone think of a non-iterative way to generate a decreasing geometric sequence in R? For example, for a hypothetical function dg, I would like: dg(20) [1] 20 10 5 2 1 where I am using integer division by 2 to get each subsequent value in the sequence. There is of course:

Re: [R] creating a reverse geometric sequence

2010-05-23 Thread Duncan Murdoch
Erik Iverson wrote: Hello, Can anyone think of a non-iterative way to generate a decreasing geometric sequence in R? For example, for a hypothetical function dg, I would like: dg(20) [1] 20 10 5 2 1 where I am using integer division by 2 to get each subsequent value in the sequence.

Re: [R] creating a reverse geometric sequence

2010-05-23 Thread Dan Davison
Erik Iverson er...@ccbr.umn.edu writes: Hello, Can anyone think of a non-iterative way to generate a decreasing geometric sequence in R? For example, for a hypothetical function dg, I would like: dg(20) [1] 20 10 5 2 1 where I am using integer division by 2 to get each subsequent value

Re: [R] creating a reverse geometric sequence

2010-05-23 Thread Ben Bolker
Erik Iverson eriki at ccbr.umn.edu writes: Can anyone think of a non-iterative way to generate a decreasing geometric sequence in R? Reduce(%/%,rep(2,4),init=20,accum=TRUE) __ R-help@r-project.org mailing list

Re: [R] creating a reverse geometric sequence

2010-05-23 Thread David Winsemius
On May 23, 2010, at 1:43 PM, Erik Iverson wrote: Hello, Can anyone think of a non-iterative way to generate a decreasing geometric sequence in R? For example, for a hypothetical function dg, I would like: dg(20) [1] 20 10 5 2 1 where I am using integer division by 2 to get each