[R] recursively divide a value to get a sequence

Keith Jewell k.jewell at campden.co.uk
Wed Jul 9 12:38:27 CEST 2008


> a.start <- 15000
> a.step <- 5
> a.length <- 9
> c(a.start*a.step^-(0:(a.length-2)),0)

"Anne-Marie Ternes" <amternes at gmail.com> wrote in message 
news:335d76380807090240o20064c32xb40ca6025bf8d959 at mail.gmail.com...
> Hi,
>
> if given the value of, say, 15000, I would like to be able to divide
> that value recursively by, say, 5, and to get a vector of a determined
> length, say 9, the last value being (set to) zero- i.e. like this:
>
> 15000 3000 600 120 24 4.8 0.96 0.192 0
>
> These are in fact concentration values from an experiment. For my
> script, I get only the starting value (here 15000), and the factor by
> which concentration is divided for each well, the last one having, by
> definition, no antagonist at all.
>
> I have tried to use "seq", but it can "only" do positive or negative
> increment. I didn't either find a way with "rep", "sweep" etc. These
> function normally start from an existing vector, which is not the case
> here, I have only got a single value to start with.
>
> I suppose I could do something "loopy", but I'm sure there is a better
> way to do it.
>
> Thanks a lot for your help, hope the question is not too dumb...
>
> Anne-Marie
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list