[R] tempsum
Achim Zeileis
Achim.Zeileis at wu-wien.ac.at
Thu May 12 18:55:18 CEST 2005
?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 at 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
>
More information about the R-help
mailing list