I follow this code and worked:
df=NULL
files<- list.files('tasmax/ssp370',pattern='*.nc',full.names=TRUE)
for(i in seq_along(files)) {
nc = nc_open(files[i])code
tasmax<-ncvar_get(nc,"tasmax")
nc_close(nc)
cbind(df,tasmax)->df
}
df<-as.data.frame(df)
write.csv2(df,file="data.csv")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…