WriteHarmonizedData: Write a Harmonized Data File

View source: R/functioncollection_Harmonized.R

WriteHarmonizedDataR Documentation

Write a Harmonized Data File

Description

This is a convenience wrapper function to export a data frame to the required Harmonized Data File format. See the HYPEObsMetadataTools documentation.

Usage

WriteHarmonizedData(
  df,
  filename = "",
  replace.accents = FALSE,
  strip.punctuation = FALSE,
  ignore.cols = NULL,
  nThread = NULL
)

Arguments

df

Data frame containing the harmonized data.

filename

Path to and file name (including ".csv" file extension) of the Harmonized Data CSV file to export. Windows users: Note that Paths are separated by '/', not '\'.

replace.accents

Logical, if TRUE, then accented characters (e.g. ä, ö, å) will be replaced with non-accented characters in all strings. If FALSE, then strings will be left unmodified.

strip.punctuation

Logical, if TRUE, then punctuation characters (e.g. "-", ".", ".") will be removed from all strings. If FALSE, then strings will be left unmodified.

ignore.cols

Vector of columns in df that should be ignored when replace.accents or strip.punctuation are set to TRUE.

nThread

Integer, set number of threads to be used when writing file. If NULL (default), then the output of data.table::getDTthreads will be used.

Details

WriteHarmonizedData is a convenience wrapper function of fread to export harmonized data in the HYPEObsMetadataTools Harmonized Data Format. The function checks that all required columns are present, includes options to format strings, and exports data to output CSV files with the correct encoding and formatting.

Value

WriteHarmonizedData exports a CSV file if filename is specified. Otherwise, the function outputs a data frame to the console.

Examples

df <- data.frame(
  "STATION_ID" = "A1",
  "DATE_START" = "2002-06-18 12:00",
  "DATE_END" = "2002-06-18 12:00",
  "PARAMETER" = "NH4_N",
  "VALUE" = 0.050,
  "UNIT" = "mg/L",
  "QUALITY_CODE" = "AA"
)
WriteHarmonizedData(df)


HYPEtools documentation built on Sept. 11, 2024, 8:34 p.m.