tbl_xts — tbl_xts • tbl2xts
Description: This function converts data from a tbl_df() format into a xts format. Note that the dataframe must be a data.frame or tbl_df, and either the first column must be a valid date column, or there must be one column named date, Date or DATE to order by. tbl_xts also allows the user to specify the columns to be transformed to xts, as well as an option for spreading by a single character or factor type column. See the example for details.

# tbl_xts

Source: `R/tbl_xts.R`
`tbl_xts.Rd`

This function converts data from a tbl_df() format into a xts format. Note that the dataframe must be a data.frame or tbl_df, and either the first column must be a valid date column, or there must be one column named date, Date or DATE to order by. tbl_xts also allows the user to specify the columns to be transformed to xts, as well as an option for spreading by a single character or factor type column. See the example for details.

    tbl_xts(tblData, cols_to_xts, spread_by, spread_name_pos)

## Arguments

tblData | A tbl_df type dataframe
cols_to_xts | Specify the columns to be converted to xts format. If not provided, it will by default transform all numeric columns to xts.
spread_by | A character or factor type column used to create xts series by. See example.
spread_name_pos | Add the column name of the column used to spread_by as a Suffix, Prefix or None. Defaults to Suffix (puts spread_by name at end of colname, separated by an underscore).

## Value

A xts dataframe, with columns xts series ordered by the first (date) column.

## Examples

    if (FALSE) {
    library(dplyr)
    library(tbl2xts)
    data(TRI)
    tbl_xts(tbl2xts::TRI, cols_to_xts = TRI, spread_by = Country)
     # tbl - xts - tbl:
    tbl_xts(tbl2xts::TRI, cols_to_xts = TRI, spread_by = Country) %>% xts_tbl()
    }