How to build a time series with a delay?

I am trying to make some quick graphs for search analysis and ask the following question:

How can I build a time series in ggplot? I am trying to do something like this:

 ggplot(data,aes(x=xdata,y=xdata-1)+geom_point()

But it xdata-1subtracts 1 from xdatainstead of reading the previous value xdata.

ggplotdoesn't seem to have an equivalent lag.plot, and I found a function called gglagplotin the package ggfortifythat seems to be exactly what I want, but which is not available in the latest version of R (currently 3.2).

+4
source share
1 answer

You can use tailto get the retarded version of the vector:

tail(x,-1)

ggplot2 , , , . :

x= 1:10
qplot(x=x,y=c(tail(x,-1),0))

- lag stats, , .

+5

All Articles