# NOT RUN {
## Create a new NetCDF4 dataset and define types
file1 <- tempfile("type.inq_", fileext=".nc")
nc <- create.nc(file1, format="netcdf4")
# Define a type of each class:
type.def.nc(nc, "blob", "opaque", size=128)
type.def.nc(nc, "vector", "vlen", basetype="NC_FLOAT")
type.def.nc(nc, "factor", "enum", basetype="NC_INT",
names=c("peanut butter", "jelly"),
values=c(101, 102))
type.def.nc(nc, "struct", "compound",
names=c("siteid", "height", "colour"),
subtypes=c("NC_INT", "NC_DOUBLE", "NC_SHORT"),
dimsizes=list(NULL, NULL, c(3)))
# Inquire about the types:
typeids <- grp.inq.nc(nc)$typeids
for (typeid in typeids) {
print(type.inq.nc(nc, typeid))
}
close.nc(nc)
unlink(file1)
# }
Run the code above in your browser using DataLab