[R] Geometric progression

From: Andre Nathan <andre_at_digirati.com.br>
Date: Sun, 24 Feb 2008 23:26:05 -0300


Hi

I'm pretty sure there's some built-in function to do the equivalent of this, but I couldn't find one anywhere:

gp <- function(init, mult, n)
{
  if (n == 1)
    init
  else
    pg(c(init, init[length(init)] * mult), mult, n-1) }

> gp(1, 2, 10)

 [1] 1 2 4 8 16 32 64 128 256 512 1024

Any pointers?

Thanks,
Andre



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 Mon 25 Feb 2008 - 02:27:25 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 Mon 25 Feb 2008 - 03:30:17 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