as_CF: Create a 'CFVariable' instance from an R object

View source: R/makeCFObjects.R

as_CFR Documentation

Create a CFVariable instance from an R object

Description

With this function you can convert an R object into a CFVariable. This can be an array, matrix or vector of type logical, integer, numeric or character.

Usage

as_CF(name, values)

Arguments

name

The name of the CFVariable to create.

values

The data of this object. This can be an array, matrix or vector of type logical, integer, numeric or character.

Details

Dimnames on the R object will be converted to instances of a CFAxis descendant class, depending on their values. If the dimnames along a dimension of the R object can be converted to numeric, then it will be an instance of CFAxisNumeric. If the dimnames are character, a first attempt is made to create a CFAxisTime (i.e. the dimnames have to represent timestamps), failing that a CFAxisCharacter will be created. If no dimnames are set, an instance of CFAxisDiscrete is generated.

The axes of the CFVariable are oriented as in the R object. Note that this is different from standard practice in the netCDF community and the portability of saved datasets is thus limited. You can improve this situation by setting the orientation of the axes and by adding attributes.

After creation of the CFVariable, it is recommended to set other properties, such as attributes or a coordinate reference system.

Value

An instance of class CFVariable.


ncdfCF documentation built on Sept. 13, 2025, 5:07 p.m.