在R中的函数内循环输入文件

时间:2012-02-02 09:45:55

标签: r

我正在尝试在R中使用这个代码来处理引导函数,但是我不知道如何告诉函数它必须循环输入文件。

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"))
    }

一堆谢谢。

1 个答案:

答案 0 :(得分:1)

使用lapply

data_from_txt_files <- lapply(raw, read.table)