【发布时间】:2018-09-07 09:51:33
【问题描述】:
我有以下包含日期的数据集:
> dates
[1] "20180412" "20180424" "20180506" "20180518" "20180530" "20180611" "20180623" "20180705" "20180717" "20180729"
我正在尝试创建一个列表,其中每个位置的名称为“Coherence_”+dates 中的第一个和第二个日期。所以在output1[1] 我会有Coherence_20180412_20180424。然后在output1[2] 我会有Coherence_20180506_20180518 等。
我从这段代码开始,但它没有按照我需要的方式工作:
output1<-list()
for (i in 1:5){
output1[[i]]<-paste("-Poutput1=", S1_Out_Path,"Coherence_VV_TC", dates[[i]],"_", dates[[i+1]], ".tif", sep="")
}
你有什么建议吗?
M
【问题讨论】:
-
matrix(dates, 2)然后在上面使用apply(..., 2, ...)。
标签: r list loops for-loop iteration