Re: [R] tempsum

From: Dimitris Rizopoulos <dimitris.rizopoulos_at_med.kuleuven.ac.be>
Date: Fri 13 May 2005 - 03:08:34 EST

maybe you can find cumsum() helpful, e.g.,

cumsum(1:5)

Best,
Dimitris



Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium

Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
     http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm


> hi,
>
> i'd like to calculate a temperatursum, adding the value of each
> element.
> let's say the data looks like this:
>
> x<-c(1,2,3,4,5)
> what i want to do, is ploting not the sum in the end but all the
> subresults, too,
> so my vector holds:
> x[i]
> [1]
> 1,3,6,10,15
> here is what i tried, which seems to be right to me, bu doesn't work
> out:
>
> x<-c(1,2,3,4,5)
> i<-1
> j<-1
> z[j]<-x[i]+x[i+1]
> p<-z[j]
> j<-2:4
> i<-3:5
> z[j]<-z[j-1]+x[i]
> plot (c(p,z[j])
>
> what i get is:
> [1] 6.0 12.0 9.2 18.0
>
> any sugestions? lars
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri May 13 03:14:44 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:44 EST