在 R 中将 apply 函数与 modwt 一起使用时未使用的参数

Unused argument when using apply function with modwt in R

我希望将 modwt 函数应用于我拥有的 XTS 对象,这个 XTS 对象 (wideRawXTS) 有 12 列。

此代码以前对我有效,没有任何错误,直到今天晚上我才收到此错误。我已经阅读了一些关于未使用参数的其他线程,并且我已经多次重新启动我的会话但没有成功使用 .rs.restartR()

错误与函数中未使用的参数有关,我不完全确定是哪个函数,但我猜它是 modwt。

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

当我从 apply 函数中删除过滤器参数时,错误消失了,但它随后搞砸了我的其余代码。

报错的代码段如下:

###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")

我已经查阅了 modwt (?modwt) 的帮助指南并且 filter 参数有效,所以我完全不知道为什么它会抛出错误。

我检查了我的其余代码是否有重复的函数名称,并且有 none。

其他线程的一些其他建议是使用显示以下内容的 conflicts()。我可以看到在 wavelets 和 waveslim 包中都调用了 modwt,即使我在代码开头注释掉了该包并重新启动了会话。有没有更好的方法来清除我的会话?

Here 是 link 我正在使用的 wideRawXTS 文件的输入

> 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"

另一个建议是使用 sessioninfo() 显示:

> 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

尝试像 wavelets::modwt 中那样显式添加命名空间,以确保它不会拾取您也已附加的 waveslim。