I want to modify a specific function in R, called strata.bh, stratification package. I write the function in order to obtain the code:
> strata.bh
function (x, bh, n = NULL, CV = NULL, Ls = 3, certain = NULL,
alloc = list(q1 = 0.5, q2 = 0, q3 = 0.5), takenone = 0, bias.penalty = 1,
takeall = 0, takeall.adjust = TRUE, rh = rep(1, Ls), model = c("none",
"loglinear", "linear", "random"), model.control = list())
{
call.ext <- match.call()
out <- valid_args(obj_fct = as.list(environment()), call.ext = call.ext)
N <- out$N
findn <- out$findn
L <- out$L
rhL <- out$rhL
takenone <- out$takenone
takeall <- out$takeall
certain <- out$certain
xnoc <- out$xnoc
Nc <- out$Nc
Nnoc <- out$Nnoc
q1 <- out$q1
q2 <- out$q2
q3 <- out$q3
nmodel <- out$nmodel
beta <- out$beta
sig2 <- out$sig2
ph <- out$ph
pcertain <- out$pcertain
gamma <- out$gamma
epsilon <- out$epsilon
args <- out$args
out <- init_stat(obj_fct = as.list(environment()))
EX <- out$EX
EX2 <- out$EX2
EYc <- out$EYc
bhfull <- c(min(x), bh, max(x) + 1)
strata.bh.internal(bhfull = bhfull, takeallin = takeall,
takeall.adjust = takeall.adjust, obj_fct = as.list(environment()))
}
After this I paste the same code function, changing just the name:
> stratas.bh<-function ...
I create a vector x and I try to apply the 'new' function, but I get this error code:
> x<-c(1,2,3,4,5,6,7,8,9,10);
>stratas.bh(x, bh=c(2,7), CV=3)
Error in stratas.bh(x) : could not find function "valid_args"
Do I need to load another package?!