我希望将modwt函数应用于我拥有的XTS对象,这个XTS对象(wideRawXTS)有12列。
此代码之前曾为我工作过没有任何错误,只有今晚我收到此错误。我已经阅读了一些关于未使用的参数的其他线程,并且我已经多次使用.rs.restartR()
重新启动了我的会话1}}
错误与函数中未使用的参数有关,这个函数我并不完全确定,但我猜它是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)的帮助指南,并且过滤器参数有效,所以我完全不知道它为什么会抛出错误。
我已经检查了我的其余代码是否有重复的函数名称,但没有。
其他线程的其他一些建议是使用conflict()来显示以下内容。我可以看到modwt在wavelets和wavelim包中都被调用,即使我在代码的开头注释掉了这个包并重新启动了会话。有没有更好的方法来清除我的会话?
Here是指向我正在使用的wideRawXTS文件的dput的链接
> 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
答案 0 :(得分:1)
尝试在wavelets::modwt
中明确添加名称空间,以确保它不会拾取您已经附加的wavelim。