as.xts.data.table

0th

Percentile

Efficient data.table to xts conversion

Efficient conversion of data.table to xts, data.table must have POSIXct or Date type in first column.

Usage
as.xts.data.table(x, …)
Arguments
x

data.table to convert to xts, must have POSIXct or Date in the first column. All others non-numeric columns will be omitted with warning.

ignored, just for consistency with generic method.

See Also

as.data.table.xts

Aliases
  • as.xts.data.table
Examples
# NOT RUN {
if (requireNamespace("xts", quietly = TRUE)) {
  sample.dt <- data.table(date = as.Date((Sys.Date()-999):Sys.Date(),origin="1970-01-01"),
                          quantity = sample(10:50,1000,TRUE),
                          value = sample(100:1000,1000,TRUE))
  # print data.table
  print(sample.dt)
  # print head of xts
  print(head(as.xts.data.table(sample.dt))) # xts might not be attached on search path
}
# }
Documentation reproduced from package data.table, version 1.12.6, License: MPL-2.0 | file LICENSE

Community examples

Looks like there are no examples yet.