From a THREDDS server, I’m using the NetcdfSubset portal to obtain a spatial subset of my climate data set of interest. Since the files I need are too big to download from their HTTP server, they instead give me an OPeNDAP URI with the spatial subset info. I then pass that to nccopy from the NetCDF library.
Then, I installed CDO and wrote a script to do the monthly means for all the files: it averages a daily time step file into a monthly averaged (or whatever metric you choose) file.
cdo monmean foo_hourly_or_daily.nc foo_monthly_mean.nc
Then, I installed nco to flip the axes.
ncpdq -a lat,lon in.nc out.nc
Then, I imported the correctly-oriented files into R.
rm(list = ls()) library(raster) library(rgdal) library(ncdf4) setwd("wherever your files are") climate <- brick("filename.nc",varname="whatever your climate variable is")
In my case, as I think is common for climate files, longitude was on a 0-360 scale, instead of -180/180.