An optimised 'ichimoku' to 'tibble' constructor.

# S3 method for ichimoku
as_tibble(x, class, keep.attrs, ...)

Arguments

x

an object of class 'ichimoku'.

class

(optional) as a character vector, subclasses to assign to the new object.

keep.attrs

(optional) if set to TRUE, will preserve any custom attributes set on the original object.

...

arguments passed to or from other methods.

Value

A 'tibble' with S3 classes of 'tbl_df', 'tbl' and 'data.frame'. The ichimoku object index is preserved as the first column with header 'index'.

Details

This function is an S3 method for the generic function as_tibble() for class 'ichimoku'. It can be invoked by calling as_tibble(x) on an object 'x' of class 'ichimoku'.

Examples

cloud <- ichimoku(sample_ohlc_data)
tbl <- as_tibble(cloud)
str(tbl)
#> tibble [281 × 13] (S3: tbl_df/tbl/data.frame)
#>  $ index  : POSIXct[1:281], format: "2020-01-02 00:00:00" "2020-01-03 00:00:00" ...
#>  $ open   : num [1:281] 123 123 123 123 124 ...
#>  $ high   : num [1:281] 123 123 123 124 125 ...
#>  $ low    : num [1:281] 122 123 122 123 124 ...
#>  $ close  : num [1:281] 123 123 123 124 125 ...
#>  $ cd     : num [1:281] -1 1 1 1 1 1 -1 0 -1 -1 ...
#>  $ tenkan : num [1:281] NA NA NA NA NA ...
#>  $ kijun  : num [1:281] NA NA NA NA NA NA NA NA NA NA ...
#>  $ senkouA: num [1:281] NA NA NA NA NA NA NA NA NA NA ...
#>  $ senkouB: num [1:281] NA NA NA NA NA NA NA NA NA NA ...
#>  $ chikou : num [1:281] 123 123 123 124 124 ...
#>  $ cloudT : num [1:281] NA NA NA NA NA NA NA NA NA NA ...
#>  $ cloudB : num [1:281] NA NA NA NA NA NA NA NA NA NA ...

tbl2 <- as_tibble(cloud, keep.attrs = TRUE)
str(tbl2)
#> tibble [281 × 13] (S3: tbl_df/tbl/data.frame)
#>  $ index  : POSIXct[1:281], format: "2020-01-02 00:00:00" "2020-01-03 00:00:00" ...
#>  $ open   : num [1:281] 123 123 123 123 124 ...
#>  $ high   : num [1:281] 123 123 123 124 125 ...
#>  $ low    : num [1:281] 122 123 122 123 124 ...
#>  $ close  : num [1:281] 123 123 123 124 125 ...
#>  $ cd     : num [1:281] -1 1 1 1 1 1 -1 0 -1 -1 ...
#>  $ tenkan : num [1:281] NA NA NA NA NA ...
#>  $ kijun  : num [1:281] NA NA NA NA NA NA NA NA NA NA ...
#>  $ senkouA: num [1:281] NA NA NA NA NA NA NA NA NA NA ...
#>  $ senkouB: num [1:281] NA NA NA NA NA NA NA NA NA NA ...
#>  $ chikou : num [1:281] 123 123 123 124 124 ...
#>  $ cloudT : num [1:281] NA NA NA NA NA NA NA NA NA NA ...
#>  $ cloudB : num [1:281] NA NA NA NA NA NA NA NA NA NA ...
#>  - attr(*, "periods")= int [1:3] 9 26 52
#>  - attr(*, "periodicity")= num 86400
#>  - attr(*, "ticker")= chr "sample_ohlc_data"