[英]loading of many read table files in R
I have "manual" file loading. 我有“手动”文件加载。 However, I have about 20 files. 但是,我大约有20个文件。 I try to read them using loops, but I have a lot of problems with that. 我尝试使用循环阅读它们,但是与此同时我有很多问题。
manual: 手册:
library(igraph)
graph<-read.table("R_test/1_1.txt")
network_name<- c(basename("R_test/1_1.txt"))
I tried using a csv loop, but "read.table" does not read this ... 我尝试使用csv循环,但是“ read.table”不读取此信息...
setwd("/R_test/network")
ldf <- list() # creates a list
listcsv <- dir(pattern = "*.csv")
for (k in 1:length(listcsv)){
ldf[[k]] <- read.csv(listcsv[k])
}
You have to specify the length of the list to be able to assign to individual slots: 您必须指定列表的长度才能分配给各个插槽:
setwd("/R_test/network")
listcsv <- dir(pattern = "*.csv")
ldf <- vector(mode = "list", length = length(listcsv)) # creates a list
for (k in 1:length(listcsv)){
ldf[[k]] <- read.csv(listcsv[k])
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.