I have over 60 nc files for specific coordinates which contain only one variable. I want to extract the variables (tasmax) from them in a csv file. The code for one file is:
ncdata <- nc_open("data.nc")
tasmax<-ncvar_get(ncdata,"tasmax")
nc_close(ncdata)
tasmax<-as.data.frame(tasmax)
write.csv2(tasmax,file="data.csv")
I tried to make a loop for all the files but always got wrong..Any ideas?
I follow this code and worked: