Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想这采用 for 循环的形式?我有大约 100 行代码可以读取 csv 并将其内容添加到数据框中,但我需要遍历当前工作目录中的所有子目录
你没有提供很多细节,但是
for (subdir in list.dirs(recursive=FALSE)) { ## do stuff ... }
Ben 的解决方案可能接近发帖人的要求,但这可能更接近他想要的:
d = NULL for (csv in dir(pattern = "\\.csv$",full.names=TRUE,recursive=TRUE)){ d = rbind(d, read.table(csv)) }