Learn R Programming

efreadr (version 0.1.1)

read_ef_files: Load all European Fluxes CSV files in one or more directories, bind all observations and fill missing data with NA_real

Description

European fluxes CSV files are distributed as one or more zip-compressed files from http://gaia.agraria.unitus.it . Once unzipped, all CSV files are to be found in uniquely identifed directories.

Usage

read_ef_files(dirs = getwd(), level_l = NULL, aggregation = NULL, fill_value = "-9999")

Arguments

dirs
a vector of directories where fluxes files are looked for. Defaults to current directory.
level_l
level of fluxes files (defaults to NULL). Allowed levels are (currently) 3 and 4. When NULL, either L3 and L4 files are looked for.
aggregation
aggregation of data (defaults to NULL) Allowed aggregations are (currently) "h" (half-hourly) and "d" (daily). When NULL, either "d" and "h" files are looked for.
fill_value
a code for a not available (NA) observation in CSV file. When the argument is given (default behaviour) the observations with 'fill_value' values are converted to NA_real

Value

a data frame as loaded from the file, added with 'efreadr_year', 'efreadr_file_name' and 'efreadr_site_id' columns, and 'efreadr_date' column for half-hourly fluxes

Details

All CSV files in that or those directories will be loaded and returned as a single row-wise bound data frame. The function assumes the file name pattern is like "^CEIP_EC_Ln_a_[a-zA-Z0-9]5_20[0-9]2_v[0-9]2\.txt$" where n in level and a is aggregation period (optionally given as function arguments) Year, file name and site identification are added as fields in the returned data frame as 'efreadr_year', 'efreader_file_name' and 'efreader_site_id'.

Optionally (but default behaviour), unavailable measures are converted to 'NA_real' values.

Examples

Run this code
dir_name <- system.file("extdata", package = "efreadr")
read_ef_files(dir_name)

Run the code above in your browser using DataLab