as_xts(x, date_col = NULL, ...)
as_xts_(x, date_col = NULL, ...)
data.frame
class.
Must specify a date column that is of the date
class. Unused for
non-data.frame objects.xts::as.xts
.xts
object.
as_xts
is a wrapper for xts::as.xts
that includes a date_col
argument. When date_col
is specified,
the date column is used as row names during coercion to xts
class. The
date column must be in a date format (i.e. date
class).as_xts_
evaluates the date_col
using Non-Standard Evaluation
(NSE). See vignette("nse")
for details.
It is possible to coerce non-data.frame-like objects including
zoo
, timeSeries
, ts
, and irts
objects.
There is no need to specify the date_col
argument.
as_tibble
# Load libraries
library(tidyverse)
library(tidyquant)
tq_get("AAPL", get = "stock.prices") %>%
as_xts(date_col = date)
# Non-Standard Evaluation (NSE)
x <- "date"
tq_get("AAPL", get = "stock.prices") %>%
as_xts_(date_col = x)
Run the code above in your browser using DataLab