View source: R/lag_day_function.R
lag_day | R Documentation |
This function subtracts a constant from a haul data (as.Date(format = ("%Y-%m-%d")). It would be useful if one wanted to create a dataframe where dates are lagged.
lag_day(input.dat, i)
input.dat |
A dataframe that contains one column named 'HAUL_DATE'. |
i |
a constant that will be subtracted from the Haul_Date |
HAUL_DATE <- as.Date(c("2019-10-13", "2019-09-10","2019-07-11", "2019-04-27", "2019-09-09", "2019-05-27", "2019-09-14", "2019-08-24", "2019-09-28", "2019-04-18"),
format = ("%Y-%m-%d"))
HAUL_NUMBER <- 1:10
obs.dat <- data.frame(cbind(HAUL_NUMBER, HAUL_DATE))
i <- 3
lag_day(obs.dat, i)
for(i in -3:3) {
if(i == -3) new.plot.dat <- lag.day(obs.dat, i)
if(i > -3) new.plot.dat <- rbind(new.plot.dat, lag.day(obs.dat, i) )
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.