nc_mean: Calculate sample mean over the dimensions of a ncdf variable

View source: R/nctool-statistics.R

nc_meanR Documentation

Calculate sample mean over the dimensions of a ncdf variable

Description

Calculate sample mean over the dimensions of a ncdf variable

Usage

nc_mean(
  filename,
  varid,
  MARGIN = c(1, 2),
  na.rm = TRUE,
  trim = 0,
  output = NULL,
  drop = TRUE,
  compression = NA,
  verbose = FALSE,
  force_v4 = TRUE,
  ignore.case = FALSE
)

Arguments

filename

Name of the existing netCDF file to be opened.

varid

What variable to read the data from. Can be a string with the name of the variable or an object of class ncvar4. If set to NA, the function will determine if there is only one variable in the file and, if so, read from that, but if there are multiple variables in the file, an error is generated.

MARGIN

a vector giving the dimensions which the function will be applied over. It can be a character vector selecting dimension names. By default, the first two dimensions are taken.

na.rm

logical; if TRUE, any NA and NaN's are removed before the quantiles are computed.

trim

the fraction (0 to 0.5) of observations to be trimmed from each end of x before the mean is computed. Values of trim outside that range are taken as the nearest endpoint.

output

Name of the file to save results.

drop

Logical. Drop degenered dimensions (i.e. dimensions of length 1)? Not implemented.

compression

If set to an integer between 1 (least compression) and 9 (most compression), this enables compression for the variable as it is written to the file. Turning compression on forces the created file to be in netcdf version 4 format, which will not be compatible with older software that only reads netcdf version 3 files.

verbose

Print debugging information.

force_v4

If TRUE, then the created output file will always be in netcdf-4 format (which supports more features, but cannot be read by version 3 of the netcdf library). If FALSE, then the file is created in netcdf version 3 format UNLESS the user has requested features that require version 4. Deafult is TRUE.

ignore.case

If TRUE, ignore case in matching dimension names and MARGIN. Default is FALSE.


roliveros-ramos/nctools documentation built on Aug. 13, 2022, midnight