Search code examples
rapplywavelet

Unused argument when using apply function with modwt in R


I wish to apply the modwt function to an XTS object I have, this XTS object (wideRawXTS) has 12 columns.

This code has previously worked for me without any error and only this evening am I receiving this error. I have read some other threads regarding unused arguments and I have restarted my session a number of times with no success using .rs.restartR()

The error relates to an unused argument in a function, which function I am not entirely sure but I am guessing it's modwt.

Error in FUN(newX[, i], ...) : unused argument (filter = "la8")

when I remove the filter argument from the apply function the error disappears but it then screws up the rest of my code.

The section of code that is throwing the error is as follows:

###This section computes the wavelet coefficients for each of the variables####
#calculates the wavelet coefficients for each of the cells in the XTS object
wideRawWavelet <- apply(wideRawXTS, 
                        2, 
                        modwt,
                        n.level = 10,
                        boundary = "periodic",
                        filter = "la8")

I've consulted the help guide for modwt (?modwt) and the filter argument is valid so I am completely lost as to why it's throwing an error.

I've checked the rest of my code for duplicate function names and there are none.

Some other suggestions from the other threads are to use conflicts() which shows the following. I can see that modwt is called in both wavelets and and waveslim packages even though I have commented out that package in the beginning of my code and restarted the session. Is there a better way to purge my session?

Here is a link to a dput of the wideRawXTS file I am using

> conflicts(detail=TRUE)
$.GlobalEnv
[1] "colnames" "eigen"   

$`package:waveslim`
[1] "dwt"    "idwt"   "imodwt" "modwt"  "mra"    "pm"    

$`package:rJava`
 [1] "show"          "show"          "show"          "head"          "str"           "tail"          "new"           "show"         
 [9] "anyDuplicated" "duplicated"    "rev"           "sort"          "unique"       

$`package:ggplot2`
[1] "arrow"    "unit"     "Position"

$`package:Rcpp`
[1] "show"       "show"       "show"       "prompt"     "initialize" "show"       "formals<-" 

$`package:wavelets`
[1] "dwt"    "idwt"   "imodwt" "modwt"  "mra"   

$`package:xts`
[1] "first" "last" 

$`package:mice`
[1] "version"

$`package:VIM`
[1] "sleep"

$`package:data.table`
 [1] "first"   "last"    "dcast"   "melt"    "hour"    "isoweek" "mday"    "minute"  "month"   "quarter" "second"  "wday"    "week"   
[14] "yday"    "year"   

$`package:grid`
[1] "arrow" "unit" 

$`package:colorspace`
[1] "show"   "show"   "show"   "plot"   "coerce" "show"  

$`package:imputeTS`
[1] "na.locf"

$`package:reshape2`
[1] "dcast" "melt" 

$`package:lubridate`
 [1] "show"        "show"        "hour"        "isoweek"     "mday"        "minute"      "month"       "pm"          "quarter"    
[10] "second"      "show"        "wday"        "week"        "yday"        "year"        "Arith"       "Compare"     "show"       
[19] "as.difftime" "date"        "intersect"   "setdiff"     "union"      

$`package:zoo`
[1] "na.locf"         "as.Date"         "as.Date.numeric"

$`package:gplots`
[1] "lowess"

$`package:stats`
[1] "lowess"

$`package:graphics`
[1] "plot"

$`package:utils`
[1] "head"   "prompt" "str"    "tail"  

$`package:datasets`
[1] "sleep"

$`package:methods`
 [1] "show"       "show"       "show"       "Arith"      "coerce"     "Compare"    "initialize" "new"        "show"       "body<-"    
[11] "kronecker" 

$`package:base`
 [1] "anyDuplicated"   "as.Date"         "as.Date.numeric" "as.difftime"     "body<-"          "colnames"        "date"           
 [8] "duplicated"      "eigen"           "formals<-"       "intersect"       "kronecker"       "Position"        "rev"            
[15] "setdiff"         "sort"            "union"           "unique"          "version"

And the other suggestion is to use sessioninfo() which shows:

> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_Ireland.1252  LC_CTYPE=English_Ireland.1252    LC_MONETARY=English_Ireland.1252 LC_NUMERIC=C                    
[5] LC_TIME=English_Ireland.1252    

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

other attached packages:
 [1] W2CWM2C_2.0        wavemulcor_2.1.0   waveslim_1.7.5     xlsx_0.5.7         xlsxjars_0.6.1     rJava_0.9-8        ggplot2_2.2.1     
 [8] GGally_1.3.1       RColorBrewer_1.1-2 Amelia_1.7.4       Rcpp_0.12.11       wavelets_0.3-0     MTS_0.33           xts_0.10-0        
[15] mice_2.30          MissMech_1.0.2     VIM_4.7.0          data.table_1.10.4  colorspace_1.3-2   imputeTS_2.5       corrplot_0.77     
[22] reshape2_1.4.2     lubridate_1.6.0    zoo_1.8-0          gplots_3.0.1      

loaded via a namespace (and not attached):
 [1] tseries_0.10-42       splines_3.3.2         gtools_3.5.0          TTR_0.23-1            sp_1.2-5              robustbase_0.92-7    
 [7] lattice_0.20-34       quantreg_5.33         quadprog_1.5-5        minqa_1.2.4           Matrix_1.2-7.1        plyr_1.8.4           
[13] timeDate_3012.100     SparseM_1.77          mvtnorm_1.0-6         scales_0.4.1          gdata_2.18.0          fGarch_3010.82.1     
[19] lme4_1.1-13           MatrixModels_0.4-1    tibble_1.3.3          mgcv_1.8-15           car_2.1-5             nnet_7.3-12          
[25] lazyeval_0.2.0        pbkrtest_0.4-7        quantmod_0.4-10       survival_2.41-3       magrittr_1.5          forecast_8.1         
[31] laeken_0.4.6          nlme_3.1-128          MASS_7.3-45           foreign_0.8-67        class_7.3-14          tools_3.3.2          
[37] stringr_1.2.0         munsell_0.4.3         e1071_1.6-8           vcd_1.4-3             timeSeries_3022.101.2 stinepack_1.3        
[43] caTools_1.17.1        rlang_0.1.1           nloptr_1.0.4          bitops_1.0-6          boot_1.3-18           gtable_0.2.0         
[49] fracdiff_1.4-2        reshape_0.8.6         fBasics_3011.87       KernSmooth_2.23-15    stringi_1.1.5         parallel_3.3.2       
[55] rpart_4.1-10          DEoptimR_1.0-8        lmtest_0.9-35

Solution

  • try adding the namespace explicitly as in wavelets::modwt, to ensure it's not picking up the waveslim one you also have attached.