首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何从R中的各个子文件夹中包含的文件中堆叠各个栅格层?

如何从R中的各个子文件夹中包含的文件中堆叠各个栅格层?
EN

Stack Overflow用户
提问于 2018-05-31 23:51:11
回答 2查看 146关注 0票数 1

我正在使用栅格层。我在一个父文件夹中有10个子文件夹。每个子文件夹包含数百个栅格。我想为每个子文件夹应用一个脚本,并为我的每个子文件夹创建几个堆栈。

代码语言:javascript
复制
#List all my subfolders in my parent folder
list_dirs<- list.dirs(path/parentfolder/, recursive = F) 

for (i in list_dir){

# set the working directory to the subfolder i
setwd(i) 

# List all the files with a certain pattern in the subfolder i
s<- list.files(path=setwd(i), pattern = "cool", recursive=F)

# I do not see how I can create a stack for each of my subfolders here.
#I should have an index i somewhere in the last line.

ss<- stack(s)

}

作为最终输出,我希望我的10个子文件夹中的每一个都有10个堆栈。我是新来R的,谢谢!

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50628255

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档