Conversion of a data into time series object

The question’s use of the xts function is incorrect but it doesn’t really matter since xts cannot represent that sort of data in the first place. xts requires an index class that represents dates or date/times such as Date or POSIXct but here we have plain numbers. Create a zoo series instead.

library(zoo)

# test data
INTC <- data.frame(ts = 930:935, close = 18.55)

z <- read.zoo(INTC); z
##   930   931   932   933   934   935 
## 18.55 18.55 18.55 18.55 18.55 18.55 

Browse More Popular Posts

Leave a Comment