0

I have a dataset of five stocks and their returns that I'm trying to modify the dataset and eventually create a covariance matrix. I've been trying the function below to convert the dataset into a time series object using the "xts" function:

log_ret_xts <- log_ret_tidy %>%
  spread(symbol, value = ret) %>%
  tk_xts()

I get the error message Error in tk_xts(.) : could not find function "tk_xts"

I should have all needed packages installed, any help?

M--
  • 25,431
  • 8
  • 61
  • 93
hsso
  • 1
  • 1
  • "All needed packages" sounds a bit non-transparent. I assume you did load `{timetk}` via `library(timetk)`? – dimfalk Oct 12 '22 at 07:45
  • I did load 'library(timetk)', yes. I finally got it to work via another solution but would still be interested in knowing what the issue is with the xts -fuction – hsso Oct 19 '22 at 14:10
  • Would you mind sharing? `tk_xts()` is a function coming from `{timetk}`, not `{xts}`, c.f. their particular NAMESPACE files. Maybe try calling the function explicitly via `timetk::tk_xts()`? – dimfalk Oct 19 '22 at 16:15

0 Answers0