R中的Bootstrap错误

问题描述 投票:1回答:2

我正试图引导我的数据,它的样本如下

AveOn   AveOff  AveLd   DWELL_SEC
0.3     0.1     5.9     14
0.3     0.1     5.9     17
0.3     0.1     5.9     9
1.1     1.5    25.3     21
1.1     1.5    25.3     159
1.1     1.5    25.3     14
1.1     1.5    25.3     13
1.1     1.5    25.3     18
1.1     1.5    25.3     26
1.1     1.5    25.3     19
1.1     1.5    25.3     17
1.1     1.5    25.3     24
1.1     1.5    25.3     27

我写了以下代码

library(xlsx)
library(bootstrp)
rawData <- read.xlsx("9660.xlsx")
load<-function(AveLd,AveOff,AveOn,DWELL_SEC)
+ + sum((AveLd-AveOff)+AveOn)

 bootstrap(rawData,load,10000,replace=true)

我一直在犯这个错误

Error in n * nboot : non-numeric argument to binary operator 

有没有办法解决它

感谢您的时间和帮助

r numeric bootstrapping
2个回答
0
投票

你搞砸了论点......

bootstrap(rawData, func=load, nboot=10000, replace=TRUE)

有关详细信息,请查看功能帮助

?bootstrap 

-1
投票
library(xlsx)
library(bootstrap)
rawData <- read.xlsx("C:\\Users\\TAQWA\\Downloads\\9660.xlsx",1)
#load<-function(AveLd,AveOff,AveOn,DWELL_SEC)
#  + + sum((AveLd-AveOff)+AveOn)
#bootstrap(rawData,10000,load())
three_d_array <- array(0,dim = c(270, 6, 20))
for (i in 1:20){
candy = 1:nrow(rawData)
B=sample(candy,nrow(rawData) , replace=T)
a=rawData[B,]
three_d_array[,,i]=as.matrix(a)
}
© www.soinside.com 2019 - 2024. All rights reserved.