Re: [R] tempsum

From: Achim Zeileis <Achim.Zeileis_at_wu-wien.ac.at>
Date: Fri 13 May 2005 - 02:55:18 EST

?cumsum
Z

On Thu, 12 May 2005 18:48:32 +0200 Lars wrote:

> 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:09:21 2005

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