-1

I have a weird problem with converting a data frame into a time series:

1) I have a data frame which has 420,000 rows. It looks like:

 > numsdf[5760:5764,]

              YR--MODAHRMN TEMP DEWP
 7712 1973-04-29 00:00:00   82   35
 7713 1973-04-29 01:00:00   78   41
 7714 1973-04-29 02:00:00   73   45
 7715 1973-04-29 03:00:00   66   41
 7716 1973-04-29 04:00:00   61   46

2) I convert this into a time series. No problem up to here.

> tsdf=with(numsdf, xts(numsdf$TEMP, order.by = numsdf$"YR--MODAHRMN"))

3) Problem 1: For some reason the TEMP column becomes V1. No idea why.

 > tsdf[5760:5764,]
                      [,1]
 1973-04-29 00:00:00   82
 1973-04-29 01:00:00   78
 <NA>                  73
 1973-04-29 03:00:00   66
 1973-04-29 04:00:00   61

3) Problem 2:

Some dates, (randomly and for no apparent reason) are changed to . As in the example above, I don't know why this happens. Thanks

Oniropolo
  • 879
  • 2
  • 12
  • 18

1 Answers1

0

The TEMP column becomes V1 because numsdf$TEMP is a vector and doesn't have a column name, so the xts constructor gives it a default column name of V1.

Some datetimes are likely NA because they occur when daylight saving time starts in your local timezone.

You need to provide more specific details (via a reproducible example) if you want people to be able to provide more specific solutions.

Community
  • 1
  • 1
Joshua Ulrich
  • 173,410
  • 32
  • 338
  • 418
  • Thank you very much. I noticed this is the second time you answer my questions and I thank you enormously. I'll work on providing a good reproducible example next time. – Oniropolo Feb 22 '15 at 04:13