Well, maybe. Whether it's +24 or -24 depends on what you mean by "one day lag." I suspect you mean -24, but perhaps this will help you decide:
test <- ts(1:72, frequency = 24) plot(lag(test,24)) plot(lag(test,-24)) Note that the +24 moves the time base back 24 observable units (= hours) and -24 moves it forward 24 hours. This means that the day 2 observations are those from day 1, etc., which is usually what is wanted for lag. But you decide. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Aug 7, 2018 at 7:47 AM, Edoardo Silvestri < silvestri.cas...@gmail.com> wrote: > I have an hourly database and I defined a variable as follows: > time<-ts(data$variable, frequency=24) > > If i need to create the variables with one day lag, the corresponding > command is lag(time,24)? > > Thank you > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/ > posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.