It looks like you are using the ncdf
package in R. If you can, I recommend using the updated ncdf4
package, which is based on Unidata's netcdf version 4 library (link).
Back to your problem. I use the ncdf4
package, but I think the ncdf
package works the same way. When you call the function get.var.ncdf
, you also need to explicitly supply the name of the variable that you want to extract. I think you can get the names of the variables using names(test$var)
.
So you need to do something like this:
# Open the nc file
test = open.ncdf("rr_0.25deg_reg_1980-1994_v8.0.nc")
# Now get the names of the variables in the nc file
names(test$var)
# Get the data from the first variable listed above
# (May not fit in memory)
data = get.var.ncdf(test,varid=names(test$var)[1])
# If you only want a certain range of data.
# The following will probably not fit in memory either
# data = get.var.ncdf(test,varid=names(test$var)[1])[1:464,1:201,1:365]
For your problem, you would need to replace varid=names(test$var)[1]
above with varid='VARIABLE_NAME'
, where VARIABLE_NAME
is the variable you want to extract.
Hope that helps.
EDIT:
I installed the ncdf
package on my system, and the above code works for me!