Reputation: 1
I am trying to work on this code in R for a bootstrap function, but I don't have an idea how to tell the function that it has to loop through the input files.
raw <- list.files(pattern="*.txt")
prs <- list.files(pattern="*.pres")
for (i in seq_along(raw))
{
a <- read.table(raw[i])
bb <- read.table(prs[i])
AUC <- function(p,ind){
pres <- p[ind]
cat <- c(pres,(read.table(abs[i])))
name <- c(rep(1,length(pres)), rep(0,length(a)))
predic <- prediction(cat,name)
return(performance(predic,"auc")@y.values[[1]])
}
bb <- read.table(prs[i])
b1 <- boot(bb,AUC,100)
b2 <- boot.ci(b1,conf=c(0.95), type=c("bca"))
}
bunch of thanks.
Upvotes: 0
Views: 354
Reputation: 121077
Use lapply
.
data_from_txt_files <- lapply(raw, read.table)
Upvotes: 1