[英]How to save the output of for loop with nested while loop
簡單的方法:
output <- data.frame(latitude = numeric(0),
matrix(numeric(0), ncol=365))
names(output) <- gsub("X", "day", names(my_df))
for (i in seq_len(nrow(df))){
output[i, 1] <- df$latitude[i]
j <- 1
while(j <= 365){
output[i, j + 1] <- daylength(lat = df$latitude[i], doy = j)
j <- j + 1
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.