Converting Netcdf files to R

Occasionally, I need to open .nc files. The names command does not work quite as I expected. Instead there is a names command to see all of the variables in the dataset.

library(ncdf)
data = open.ncdf(filename.nc)
print(data)  #gives an overview of some of the contents of the netcdf file
names(data$var)   #gives the actual variable names
var1_R=get.var.ncdf(data, "var1")   ## assume var1 is one of the variables in the dataset

Tags: