Dear all, I have a time serie dataset such as the following with data acquired every 15 minutes: Date Heure Profondeur Temp?rature Salinit? Turbidit? Chloration 1 2012-07-06 08:47:22 -0.144 22.469 0.011 0.000 0 2 2012-07-06 09:02:21 -0.147 22.476 0.011 0.000 0 3 2012-07-06 09:17:21 -0.139 22.498 0.011 19.323 0 4 2012-07-06 09:32:21 -0.136 22.540 0.011 19.343 0 5 2012-07-06 09:47:21 -0.141 22.510 0.011 19.321 0 6 2012-07-06 10:02:21 -0.139 22.372 0.011 19.280 0 I wonder what is the best class to use to manage such time series -- Cordialement ------------------------------------------------ Emmanuel Poizot Cnam/Intechmer B.P. 324 50103 Cherbourg Cedex Web : http://www.geoceano.fr Phone (Direct) : (00 33)(0)233887342 ou 41 Fax : (00 33)(0)233887339 ------------------------------------------------
Mr. Emmanuel, On 4 October 2012 02:43, Poizot Emmanuel <emmanuel.poizot@cnam.fr> wrote:> Dear all, > > I have a time serie dataset such as the following with data acquired every > 15 minutes: > > Date Heure Profondeur Température Salinité Turbidité Chloration > 1 2012-07-06 08:47:22 -0.144 22.469 0.011 0.000 0 > 2 2012-07-06 09:02:21 -0.147 22.476 0.011 0.000 0 > 3 2012-07-06 09:17:21 -0.139 22.498 0.011 19.323 0 > 4 2012-07-06 09:32:21 -0.136 22.540 0.011 19.343 0 > 5 2012-07-06 09:47:21 -0.141 22.510 0.011 19.321 0 > 6 2012-07-06 10:02:21 -0.139 22.372 0.011 19.280 0 > > I wonder what is the best class to use to manage such time seriesUse xts whenever dealing with timeseries, to construct: xts(data.in[,-1:2], order.by=as.POSIXct(paste(data.in[,1:2]))) Also, when you post help requests, use dput on your data set. I'm assuming it's a data.frame, but I'd be able to actually test my code if there were dput output in your question. -- H -- Sent from my mobile device Envoyait de mon portable [[alternative HTML version deleted]]
On Thu, 4 Oct 2012, Poizot Emmanuel wrote:> Dear all, > > I have a time serie dataset such as the following with data acquired every 15 > minutes: > > Date Heure Profondeur Temp?rature Salinit? Turbidit? Chloration > 1 2012-07-06 08:47:22 -0.144 22.469 0.011 0.000 0 > 2 2012-07-06 09:02:21 -0.147 22.476 0.011 0.000 0 > 3 2012-07-06 09:17:21 -0.139 22.498 0.011 19.323 0 > 4 2012-07-06 09:32:21 -0.136 22.540 0.011 19.343 0 > 5 2012-07-06 09:47:21 -0.141 22.510 0.011 19.321 0 > 6 2012-07-06 10:02:21 -0.139 22.372 0.011 19.280 0 > > I wonder what is the best class to use to manage such time seriesSee the "Time Series" task view for guidance: http://CRAN.R-project.org/view=TimeSeries> -- > Cordialement > > ------------------------------------------------ > Emmanuel Poizot > Cnam/Intechmer > B.P. 324 > 50103 Cherbourg Cedex > > Web : http://www.geoceano.fr > Phone (Direct) : (00 33)(0)233887342 ou 41 > Fax : (00 33)(0)233887339 > ------------------------------------------------ > >
On Thu, Oct 4, 2012 at 3:07 AM, Hasan Diwan <hasan.diwan at gmail.com> wrote:> Mr. Emmanuel, > > On 4 October 2012 02:43, Poizot Emmanuel <emmanuel.poizot at cnam.fr> wrote: > >> Dear all, >> >> I have a time serie dataset such as the following with data acquired every >> 15 minutes: >> >> Date Heure Profondeur Temp?rature Salinit? Turbidit? Chloration >> 1 2012-07-06 08:47:22 -0.144 22.469 0.011 0.000 0 >> 2 2012-07-06 09:02:21 -0.147 22.476 0.011 0.000 0 >> 3 2012-07-06 09:17:21 -0.139 22.498 0.011 19.323 0 >> 4 2012-07-06 09:32:21 -0.136 22.540 0.011 19.343 0 >> 5 2012-07-06 09:47:21 -0.141 22.510 0.011 19.321 0 >> 6 2012-07-06 10:02:21 -0.139 22.372 0.011 19.280 0 >> >> I wonder what is the best class to use to manage such time series > > > Use xts whenever dealing with timeseries, to construct: > xts(data.in[,-1:2], order.by=as.POSIXct(paste(data.in[,1:2]))) >If you are using xts and reading in the data from an external file then note that xts loads the zoo package and read.zoo can be used to do the actually reading: Lines <- "Date Heure Profondeur Temp?rature Salinit? Turbidit? Chloration 1 2012-07-06 08:47:22 -0.144 22.469 0.011 0.000 0 2 2012-07-06 09:02:21 -0.147 22.476 0.011 0.000 0 3 2012-07-06 09:17:21 -0.139 22.498 0.011 19.323 0 4 2012-07-06 09:32:21 -0.136 22.540 0.011 19.343 0 5 2012-07-06 09:47:21 -0.141 22.510 0.011 19.321 0 6 2012-07-06 10:02:21 -0.139 22.372 0.011 19.280 0" library(xts) # also pulls in zoo # z <- read.zoo("myfile.dat", header = TRUE, index = 1:2, tz = "") z <- read.zoo(text = Lines, header = TRUE, index = 1:2, tz = "") x <- as.xts(z) Here index = 1:2 says that the date/time index is in the first two columns and tz = "" says to interpret it as POSIXct with the indicated time zone. tz = "GMT" is another possibility. For more info on read.zoo see ?read.zoo . Also there is a document entirely devoted to read.zoo examples obtained by issuing: vignette("zoo-read") . -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
Hi, library(xts) xts(dat1[,-1:2],order.by=as.POSIXct(paste(dat1[,1],dat1[,2],sep=" "),format="%Y-%m-%d %H:%M:%S")) #Error in .subset(x, j) : only 0's may be mixed with negative subscripts xts(dat1[,3:7],order.by=as.POSIXct(paste(dat1[,1],dat1[,2],sep=" "),format="%Y-%m-%d %H:%M:%S")) #??????????????????? Profondeur Temp?rature Salinit? Turbidit? Chloration #2012-07-06 00:00:22???? -0.145????? 22.468??? 0.011???? 0.000????????? 0 #2012-07-06 00:02:21???? -0.143????? 22.475??? 0.011???? 0.000????????? 0 #2012-07-06 01:17:21???? -0.132????? 22.456??? 0.011???? 0.323????????? 0 #2012-07-06 08:47:22???? -0.144????? 22.469??? 0.011???? 0.000????????? 0 #2012-07-06 09:02:21???? -0.147????? 22.476??? 0.011???? 0.000????????? 0 #2012-07-06 09:17:21???? -0.139????? 22.498??? 0.011??? 19.323????????? 0 #2012-07-06 09:32:21???? -0.136????? 22.540??? 0.011??? 19.343????????? 0 #2012-07-06 09:47:21???? -0.141????? 22.510??? 0.011??? 19.321????????? 0 #2012-07-06 10:02:21???? -0.139????? 22.372??? 0.011??? 19.280????????? 0 A.K. ----- Original Message ----- From: Hasan Diwan <hasan.diwan at gmail.com> To: Poizot Emmanuel <emmanuel.poizot at cnam.fr> Cc: r-help at r-project.org Sent: Thursday, October 4, 2012 3:07 AM Subject: Re: [R] Class for time series Mr. Emmanuel, On 4 October 2012 02:43, Poizot Emmanuel <emmanuel.poizot at cnam.fr> wrote:> Dear all, > > I have a time serie dataset such as the following with data acquired every > 15 minutes: > > Date? ? Heure Profondeur Temp?rature Salinit? Turbidit? Chloration > 1 2012-07-06 08:47:22? ? -0.144? ? ? 22.469? ? 0.011 0.000? ? ? ? ? 0 > 2 2012-07-06 09:02:21? ? -0.147? ? ? 22.476? ? 0.011 0.000? ? ? ? ? 0 > 3 2012-07-06 09:17:21? ? -0.139? ? ? 22.498? ? 0.011 19.323? ? ? ? ? 0 > 4 2012-07-06 09:32:21? ? -0.136? ? ? 22.540? ? 0.011 19.343? ? ? ? ? 0 > 5 2012-07-06 09:47:21? ? -0.141? ? ? 22.510? ? 0.011 19.321? ? ? ? ? 0 > 6 2012-07-06 10:02:21? ? -0.139? ? ? 22.372? ? 0.011 19.280? ? ? ? ? 0 > > I wonder what is the best class to use to manage such time seriesUse xts whenever dealing with timeseries, to construct: xts(data.in[,-1:2], order.by=as.POSIXct(paste(data.in[,1:2]))) Also, when you post help requests, use dput on your data set. I'm assuming it's a data.frame, but I'd be able to actually test my code if there were dput output in your question. -- H -- Sent from my mobile device Envoyait de mon portable ??? [[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.