[R] Time Series data with data every half hour
Uwe Ligges
ligges at statistik.tu-dortmund.de
Sun Aug 28 17:51:49 CEST 2011
On 26.08.2011 17:43, Simmons, Ryan wrote:
> I am working with data from the USGS with data every 30 minutes from
> 4/27/2011 to 8/25/2011.
>
> I am having trouble with setting the frequency.
>
>
>
> My R script is below:
>
>
>
>> shavers=read.csv("shavers.csv")
>
>> names(shavers)
>
> [1] "agency_cd" "site_no" "datetime" "tz_cd" "Temp"
>
>
> [6] "X04_00010_cd" "EC25" "X05_00095_cd" "DO"
> "X06_00300_cd"
>
> [11] "pH" "X07_00400_cd"
>
>> as.POSIXct(shavers[1,3])
>
> [1] "2011-04-27 EDT"
>
>> as.POSIXct(shavers[nrow(shavers),3])
>
> [1] "2011-08-25 23:00:00 EDT"
>
>> temp=ts(shavers[,5],as.POSIXct(shavers[1,3]),frequency=48)
>
> Error in attr(data, "tsp")<- c(start, end, frequency) :
>
> invalid time series parameters specified
>
>
>
> I have also used xts:
>
>
>
>> plot(temp)
>
>> library(xts)
>
>> temp=xts(shavers[,5],order.by=as.POSIXct(shavers[,3]),frequency=48)
>
>> stl(temp,s.window='periodic')
>
> Error in stl(temp, s.window = "periodic") :
>
> series is not periodic or has less than two periods
>
>
>
> The data has very clear daily periods.
... but you failed to tell this to the R functions correctly?
> How can I configure my time
> series to analyze this?
We do not know, since we do see a reproducible example you have been
asked to provide in the posting guide.
Uwe Ligges
>
>
> Thank you very much.
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
More information about the R-help
mailing list