[R] How can I get the difference seq directly?

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Sat Nov 26 05:19:32 CET 2005


?diff

y <- diff(x)

HTH,

--sundar

å¹¿æ˜Ÿ wrote:
> Hi, R-help,
> let x<-rnorm(1000),
> now I want to get a sequence y,which is satisfied with as follow:
>  y[1]<-x[2]-x[1]
>  y[2]<-x[3]-x[2]
>  ....
>  y[999]<-x[1000]-x[999]
> 
> Is there a function in R could achieve this requirement directly?
> 
> Thank you in advance!
> 
> 
> 
> 	
> 
> ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€è‡´
> ç¤¼ï¼
>  				
> 
> ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€å¹¿æ˜Ÿ
> ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€guangxing at ict.ac.cn
> ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€2005-11-26
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ______________________________________________
> 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