Try ths:

Alive <- sum(deaths) - cumsum(deaths)


On Tue, Sep 1, 2009 at 3:48 PM, Frostygoat <frostyg...@gmail.com> wrote:

>
> Hello,
>
> For insect mortality data I'm trying to get an R script that will take
> the data from the raw form and convert it to Lx (% survival) for a
> number of treatments.  The raw data has the number of days lived for
> each individual for the respective treatment.  Thus, for example, when
> R selects the data for a single treatment I end up with the following
> vectors:
>
> >day=seq(from=0,to=6)
> >deaths=c(0,0,2,0,0,1,6)
>
> where deaths is the number of deaths on a given day. Now I need to
> create a new vector with the number alive for each day and this is
> where I'm stuck... I've tried to work various for and while loops but
> haven't had success.  The vector should be:
>
> >Alive=c(9,9,7,7,7,6,0)
>
> I realize it is a very basic problem that is easily accomplished in
> one's head or on a spreadsheet but in the context of the size of the
> data set I wish to have R do it for me. I would welcome any
> suggestions please.
>
> Best regards.
>
> ______________________________________________
> R-help@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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to