Learn R Programming

tidyquant (version 0.5.3)

as_tibble: DEPRECATED: Coerce to tibble. Enable preserving row names when coercing matrix and time-series-like objects with row names.

Description

Coerce to tibble. Enable preserving row names when coercing matrix and time-series-like objects with row names.

DEPRECATED: Use timetk::tk_tbl() instead.

Usage

as_tibble(x, preserve_row_names = FALSE, ...)

Arguments

x

A list, matrix, xts, zoo, timeSeries, etc object.

preserve_row_names

Used during coercion from matrix, xts, zoo, timeSeries, etc objects that have row names. When TRUE, creates a row.names column with names of rows as character class.

...

Additional parameters passed to the appropriate timetk::tk_tbl() function.

Value

Returns a tibble object.

Details

as_tibble is a wrapper for tibble::as_tibble that includes a preserve_row_names argument. The function is designed to coerce xts, zoo, timeSeries, ts, and irts objects that are used frequently in quantitative financial analysis. When preserve_row_names = TRUE is specified, a new column, row.names, is created during object coercion as a character class.

See Also

Examples

Run this code
# NOT RUN {
# Load libraries
library(tidyquant)

# Matrix coercion to tibble
m <- matrix(rnorm(50), ncol = 5)
colnames(m) <- c("a", "b", "c", "d", "e")
rownames(m) <- letters[1:nrow(m)]
m_tbl <- as_tibble(m, preserve_row_names = TRUE)

# xts coercion to tibble
quantmod::getSymbols("AAPL", auto.assign = FALSE) %>%
    as_tibble(preserve_row_names = TRUE)

# }

Run the code above in your browser using DataLab