[R] Class for time series
arun
smartpink111 at yahoo.com
Thu Oct 4 14:48:28 CEST 2012
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 series
Use 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.
More information about the R-help
mailing list