# NOT RUN {
## Create a new NetCDF4 dataset and define types
file1 <- tempfile("type.def_", fileext=".nc")
nc <- create.nc(file1, format="netcdf4")
# Compound type:
type.def.nc(nc, "astruct", "compound",
names=c("siteid", "height", "colour"),
subtypes=c("NC_INT", "NC_DOUBLE", "NC_SHORT"),
dimsizes=list(NULL, NULL, c(3)))
# Enum type:
type.def.nc(nc, "afactor", "enum", basetype="NC_INT",
names=c("peanut butter", "jelly"),
values=c(101,102))
# Opaque type:
type.def.nc(nc, "ablob", "opaque", size=128)
# Vlen type:
type.def.nc(nc, "avector", "vlen", basetype="NC_FLOAT")
close.nc(nc)
unlink(file1)
# }
Run the code above in your browser using DataLab