我想遍历一个数据框并从数据框中选择一个单独的列,为此我使用以下代码,但它给了我一个错误。有人可以指导我在这段代码中应该更正什么吗?
for (i in 1:3) {
cur_file <- paste(i,".csv",sep="")
curfile <- list.files(pattern = cur_file)
rd_data[i] <- read.csv(curfile, header=F,sep="\t")
col1 <- rd_data[i,1] # select the first column in the "1st" data frame
n_val[i] <- rd_data[i,2] # select the second column in the each of "ith" data frame
}