I try to convert a daily dataset to ts
, but how do you deal with leap year? so what value should I set the frequency equal to?
ts(data,start=c(2010,1,1),frequency=365)?
I would suggest using the packages zoo or xts (which relies on zoo
). With these time formats you can define the time series with or without daylight saving times or leap years.
Additionally I would suggest using the package lubridate to do timespan calculations. lubridate
makes a difference between periods and durations.
The duration class measures the exact time span between two moments in time, that you would measure on a stop watch.
In contrast a period is for example "a month". But how long is a month? Depends on which month you mean. And for example in leap years month february has a different duration, but same period length.
Whether you need the duration or the period depends on your subject and objective. With zoo
and lubridate
you can choose the one that is relevant for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With