3

I'm using the RNetCDF package in R. I'm trying to get a list of all variables names from an imported .nc datasets (I can easily get the vector of values from the few variables whose names I know, but I only know a small subset of all the variables names).

Paul Hiemstra
  • 59,984
  • 12
  • 142
  • 149
user189035
  • 5,589
  • 13
  • 52
  • 112

1 Answers1

6

I use the ncdf pacakge which I found to be much easier to install than the RNetCDF package across operating systems (notably Linux and MacOS). To get the list of variables you simply:

library(ncdf)
nc = open.ncdf('example.nc')
variables = names(nc[['var']])
Paul Hiemstra
  • 59,984
  • 12
  • 142
  • 149