write_data: Export Eddy Covariance Data

Description Usage Arguments Details

Description

Facilitates printing object x also with its units of measurement (or space efficient metadata) to a file or connection.

Usage

1
2
3
write_data(x, file = "", append = FALSE, quote = TRUE, sep = ",",
  include_units = TRUE, fill = "-", na = "-9999", col.names = TRUE,
  use_varnames = FALSE, ...)

Arguments

x

A data frame to be written with optional attributes units and varnames assigned to each column. If not a data frame it is converted by as.data.frame.

file

A character string naming a file to write or a connection that is open for writing. "" results in writing to the console.

append

A logical value, used only if file is not a connection. If TRUE, output is written below the content of the file. If FALSE, the content of the file is overwritten.

quote

A logical value (TRUE or FALSE) or a numeric vector. If TRUE, columns of class character or factor will be surrounded by double quotes. If a numeric vector, its elements should mark the indices of character or factor columns to quote. In both cases, row and column names and units are quoted if present. If FALSE, no quoting is performed.

sep

A character used as the field separator of each row.

na

A character string representing missing data values in the output.

col.names

Either a logical value (TRUE, FALSE or NA) or a character vector. If TRUE, column names of x will be included in the output. If a character vector, its elements will be used as column names. If x is supplied as vector, an attempt is made to extract meaningful variable name from its attribute varnames.

...

Further arguments passed to write.table.

units_fill

A character string representing missing values of units attribute in the output.

Details

write_data extends the possibilities of write.table so the units of measurement can also be written. However, it uses default arguments of write.csv to provide flexibility for the user and to accomodate for the most common case. The character string "-9999" is typically used to represent missing values in eddy covariance data.

Storing varnames and units attributes is practical mostly within data frames and vectors. Attribute varnames extracted from each data frame column represents names of respective variables and its main purpose is to keep variable names of isolated vectors. Attribute units extracted from each column represents units of measurement (or space efficient metadata) of respective variables that are written one line above data region. If the varnames or units attribute of given column is NULL, of length not equal to 1, or contains missing value or empty string, it is not considered meaningful. In that case the default column name produced by as.data.frame is used instead (considered only if x is supplied as vector) and unit of measurement is substituted with units_fill string. units_fill can be an empty string.

Units of measurement are considered to be part of the output header and therefore col.names and quote arguments have the effect on the way they are written.

Adapted from: openeddy - write_eddy


grahamstewart12/tidyflux documentation built on June 4, 2019, 7:44 a.m.