robjhyndman / tsfeatures

Time series features
http://pkg.robjhyndman.com/tsfeatures
253 stars 42 forks source link

Error in `[<-`(`*tmp*`, i, featurenames[[i]], value = featurelist[[i]][featurenames[[i]]]) : subscript out of bounds #23

Closed konradsemsch closed 5 years ago

konradsemsch commented 5 years ago

I'm just trying to run the following example with an additional feature specified and getting this result:

mylist <- list(sunspot.year, WWWusage, AirPassengers, USAccDeaths)
tsfeatures(mylist, features = c("binarize_mean"))
Error in `[<-`(`*tmp*`, i, featurenames[[i]], value = featurelist[[i]][featurenames[[i]]]) :    subscript out of bounds

I noted that when using any other feature than the default 4 options, the same error shows up. What could be the reason for that?

My session info is:

R version 3.6.0 (2019-04-26)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.4

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] tsfeatures_1.0.1 forcats_0.4.0    stringr_1.4.0    purrr_0.3.2      readr_1.3.1      tibble_2.1.1     tidyverse_1.2.1  aider_0.0.1.05  
 [9] tidyr_0.8.3      recipes_0.1.5    ggplot2_3.1.1    dplyr_0.8.0.1   

loaded via a namespace (and not attached):
 [1] nlme_3.1-139       fs_1.2.7           xts_0.11-2         usethis_1.5.0      lubridate_1.7.4    devtools_2.0.2     bit64_0.9-7       
 [8] httr_1.4.0         rprojroot_1.3-2    tools_3.6.0        backports_1.1.4    R6_2.4.0           rpart_4.1-15       DBI_1.0.0         
[15] lazyeval_0.2.2     colorspace_1.4-1   nnet_7.3-12        withr_2.1.2        tidyselect_0.2.5   prettyunits_1.0.2  processx_3.3.0    
[22] bit_1.1-14         curl_3.3           compiler_3.6.0     cli_1.1.0          rvest_0.3.3        xml2_1.2.0         desc_1.2.0        
[29] tseries_0.10-46    scales_1.0.0       lmtest_0.9-36      fracdiff_1.4-2     quadprog_1.5-6     callr_3.2.0        digest_0.6.18     
[36] pkgconfig_2.0.2    sessioninfo_1.1.1  rlang_0.3.4        readxl_1.3.1       TTR_0.23-4         rstudioapi_0.10    quantmod_0.4-14   
[43] generics_0.0.2     zoo_1.8-5          jsonlite_1.6       config_0.3         magrittr_1.5       Matrix_1.2-17      Rcpp_1.0.1        
[50] munsell_0.5.0      stringi_1.4.3      forecast_8.6       yaml_2.2.0         MASS_7.3-51.4      pkgbuild_1.0.3     plyr_1.8.4        
[57] blob_1.1.1         grid_3.6.0         parallel_3.6.0     crayon_1.3.4       lattice_0.20-38    haven_2.1.0        splines_3.6.0     
[64] hms_0.4.2          knitr_1.22         ps_1.3.0           pillar_1.3.1       pkgload_1.0.2      urca_1.3-0         glue_1.3.1        
[71] RPostgres_1.1.1    remotes_2.0.4      modelr_0.1.4       cellranger_1.1.0   gtable_0.3.0       assertthat_0.2.1   xfun_0.6          
[78] gower_0.2.0        prodlim_2018.04.18 broom_0.5.2        class_7.3-15       survival_2.44-1.1  timeDate_3043.102  memoise_1.1.0     
[85] lava_1.6.5         ipred_0.9-9     
robjhyndman commented 5 years ago

The error message is not very informative, but the problem is that you are not using a feature function. A feature function should return a small vector of named features. binarize_mean just converts the original time series into 0s and 1s. The package can use other feature functions as follows:

library(tsfeatures)
mylist <- list(sunspot.year, WWWusage, AirPassengers, USAccDeaths)
tsfeatures(mylist, features = c("hurst","lumpiness"))

You can see a full list of feature functions at https://pkg.robjhyndman.com/tsfeatures/articles/tsfeatures.html

We will update the package to improve the error messaging.

robjhyndman commented 5 years ago

Improved error message in https://github.com/robjhyndman/tsfeatures/commit/ce5cead9c485fa72d9669d5c678ec82f33d4d325

konradsemsch commented 5 years ago

I see. Thanks!

I did a couple more tests though and I found one example that seems like a bug to me:

mylist <- list(sunspot.year, WWWusage, AirPassengers, USAccDeaths) tsfeatures(mylist, features = c("hw_parameters"))

This one returns variables and not an entire vector right?