简体   繁体   中英

Time Series hourly data format

From the data bellow I'm trying to create a time series object with zoo package

 head(data)                            MTU    Fossil
1 01.01.2015 00:00 - 01.01.2015 01:00 (CET)   2805
2 01.01.2015 01:00 - 01.01.2015 02:00 (CET)   2714
3 01.01.2015 02:00 - 01.01.2015 03:00 (CET)   2694
4 01.01.2015 03:00 - 01.01.2015 04:00 (CET)   2563
5 01.01.2015 04:00 - 01.01.2015 05:00 (CET)   2381
6 01.01.2015 05:00 - 01.01.2015 06:00 (CET)   2438

Pick a time for the time series (depends on your application), could be the start, end or midpoint of the time range.

a$starttime=substr(a$MTU,1,16)

Write out a data frame with the correctly typed information

out = data.frame(times = strptime(a$starttime, format="%m.%d.%Y %H:%M", tz="CET"), Fossil=a$Fossil)

Convert to ts object or zoo object using your favorite method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM