Dear all, I have a data in data frame and would like to change to time
series data. Thank you for any help given.






> str(dt)'data.frame':  525600 obs. of  3 variables:
 $ time             : chr  "2014-01-01 00:00:00" "2014-01-01 00:01:00"
"2014-01-01 00:02:00" "2014-01-01 00:03:00" ...
 $ cnt_charge_events: int  0 0 0 0 0 0 0 0 0 0 ...
 $ count            : int  0 0 0 0 0 0 0 0 0 0 ...

> head(dt)                 time cnt_charge_events count
1 2014-01-01 00:00:00                 0     0
2 2014-01-01 00:01:00                 0     0
3 2014-01-01 00:02:00                 0     0
4 2014-01-01 00:03:00                 0     0
5 2014-01-01 00:04:00                 0     0
6 2014-01-01 00:05:00                 0     0


> dt_ts <- xts(dt$count, dt$time)Error in xts(dt$count, dt$time) :
  order.by requires an appropriate time-based object> head(dt_ts)Time Series:
Start = 1
End = 6
Frequency = 1
  dt_ts.date dt_ts.time dt[, 3]
1      16071          1       0
2      16071          2       0
3      16071          3       0
4      16071          4       0
5      16071          5       0
6      16071          6       0Dear


-- 
*Roslinazairimah Zakaria*
*Tel: +609-5492370; Fax. No.+609-5492766*

*Email: roslinazairi...@ump.edu.my <roslinazairi...@ump.edu.my>;
roslina...@gmail.com <roslina...@gmail.com>*
Faculty of Industrial Sciences & Technology
University Malaysia Pahang
Lebuhraya Tun Razak, 26300 Gambang, Pahang, Malaysia

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to