关于时间序列分析,我有一个列表,我想在位置1、13、25、37、49,...,192(每年的1月,例如一月)中选择列表中的元素系列(共16年)以计算这些元素的统计信息(所有层的每个像素的平均值)。
到目前为止,我得到的代码如下:
all_files_stack <- stack(list.files(path = paste0(wd, "/01_data/raster/precipitation"), pattern = ".tif", full.names = TRUE))
# to stack all .tif-files in my folder
install.packages("spatial.tools")
library(spatial.tools)
# to install and load the package "spatial.tools"
all_files_stack_list <- brickstack_to_raster_list(all_files_stack)
# to get a list of all raster layers in the rasterstack
# now I want to select the specific layers from that list to calculate the pixel-specific statistics for these layers
我已经尝试过某种方法,但是没有用:
test_jan <- all_files_stack_list[[seq(1, 192, 12)]]
Error in precip_files_all_stack_list[[seq(1, 192, 12)]] : recursive indexing failed at level 2
test_seq <- seq(1, 192, 12)
test_jan <- all_files_stack_list[[c(test)]]
Error in precip_files_all_stack_list[[c(test)]] : recursive indexing failed at level 2
人们非常感谢!