这是我在 Rstudio 中运行的代码:
library(caret)
set.seed(1)
demo <-data.frame(x1 = runif(100),x2 <- rnorm(100),y <- rbinom(100,1,0.3))
modelout <- try(train(y~.,data = demo,
method = "AMORE"),silent = FALSE)
输出如下所示:
Loading required package: AMORE
Attaching package: ‘AMORE’
The following object is masked from ‘package:caret’:
train
Error in order(x$nhid) : argument 1 is not a vector
In addition: There were 50 or more warnings (use warnings() to see the first 50)
警告信息与“AMORE”包中的“train”功能有关。如果我输入
>train
在我运行上述代码后的命令窗口中,我得到了这个函数的主体,这从 AMORE 包中很明显。
function (net, P, T, Pval = NULL, Tval = NULL, error.criterium = "LMS",
report = TRUE, n.shows, show.step, Stao = NA, prob = NULL,
n.threads = 0L)
{...
}
<environment: namespace:AMORE>
我搜索了我的路径,显然 AMORE 出现在插入符号之前:
>search()
[1] ".GlobalEnv" "package:AMORE" "package:caret" "package:ggplot2" "package:lattice"
[6] "tools:rstudio" "package:stats" "package:graphics" "package:grDevices" "package:utils"
[11] "package:datasets" "package:methods" "Autoloads" "package:base"
以下是我的会话信息:
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] AMORE_0.2-14 caret_6.0-21 ggplot2_0.9.3.1 lattice_0.20-24
loaded via a namespace (and not attached):
[1] car_2.0-19 codetools_0.2-8 colorspace_1.2-4 compiler_3.0.2 dichromat_2.0-0
[6] digest_0.6.4 foreach_1.4.1 grid_3.0.2 gtable_0.1.2 iterators_1.0.6
[11] labeling_0.2 MASS_7.3-29 munsell_0.4.2 nnet_7.3-7 plyr_1.8
[16] proto_0.3-10 RColorBrewer_1.0-5 reshape2_1.2.2 scales_0.2.3 stringr_0.6.2
[21] tools_3.0.2
我应该如何解决这个问题,以便 R 将使用“caret”中的“train”函数而不是“AMORE”中的函数?感谢您的宝贵时间,并提前感谢您的帮助。
捷通