Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
遍历R中for循环中的子目录_R_For Loop_R Raster - Fatal编程技术网

遍历R中for循环中的子目录

遍历R中for循环中的子目录,r,for-loop,r-raster,R,For Loop,R Raster,我有一个包含365个子目录的大目录,其中包含一年中每一天的图像。我创建了一个函数,希望应用于这些子目录中的每个图像。目前,我所拥有的是: library(raster) library(zebu) #List all of the 365 sub-directories within my main directory days <- list.files(full.names = F , recursive =F, pattern='*X2000*') #Apply my funct

我有一个包含365个子目录的大目录,其中包含一年中每一天的图像。我创建了一个函数,希望应用于这些子目录中的每个图像。目前,我所拥有的是:

library(raster)
library(zebu)

#List all of the 365 sub-directories within my main directory
days <- list.files(full.names = F , recursive =F, pattern='*X2000*')

#Apply my function to each directory within "days"
for(j in 1:length(days)){

    named <- paste0("full_",j)

    in.list <- list.files(recursive = T, full.names = F)

    stitched <- mosaicList(in.list)

    writeRaster(stitched, path='D:/Scratch/DataConvert/Daymet_Data/Full/' , 
    filename=named, overwrite=TRUE)
}

我是新来R的,所以我不太确定哪里出了问题。有人对解决这个问题有什么见解吗

循环中的
列表文件出现问题:

in.list <- list.files(recursive = T, full.names = F)

in.list当我尝试你的建议时,我的对象
in.list
结果是空的。如果我将我的第一行更改为((j in 1:length(days))的
{
并按照您的建议,我的
在.list
中被创建并正确地列出了目录中的图像,但是j变成了
1L
而不是它应该是的图像。哎呀,我没有更改
full.names=t
。我做了更改,现在它正在工作。感谢您的帮助!
in.list <- list.files(recursive = T, full.names = F)
in.list <- list.files(path=days[j], recursive = T, full.names = T)