export_cdt_daily: Export daily data in the format for CDT

View source: R/export_cdt_daily.R

export_cdt_dailyR Documentation

Export daily data in the format for CDT

Description

export_cdt_daily takes a data frame with daily data. This data frame is then rearranged using prepare_cdt_daily to a format suitable for use in CDT, and then written to a file or connection.

Usage

export_cdt_daily(
  data,
  station,
  element,
  date_time,
  latitude,
  longitude,
  altitude,
  metadata = NULL,
  file_path = paste0("CDT-", element, ".csv"),
  ...
)

Arguments

data

data.frame data.frame of daily climatic data in tidy format i.e. one row per day (per station) and one column per element.

station

character(1) Name of the station identifying column in data.

element

character(1) Name of the element column in data.

date_time

character(1) Name of the date column in data. Required if type = "daily". If type = "dekad" this is only needed if year, month, and dekad are not specified.

latitude

character(1) Name of the latitude column in metadata.

longitude

character(1) Name of the longitude column in metadata.

altitude

character(1) Name of the altitude column in metadata.

metadata

data.frame data.frame of station metadata. Use this is the station details are in a separate data.frame with one row per station. If specified, latitude, longitude and altitude are assumed to be in metadata and station must be in both data and metadata to facilitate joining.

file_path

character(1) A character specifying the file path and file name to export.

...

Other parameters passed to write.csv()

Value

Invisibly returns the file path of the saved data

Examples

# To write daily_niger data to CDT format
# NOT RUN:
#export_cdt_daily(data = daily_niger, station = "station_name", element = "rain", type = "daily",
#           date_time = "date", latitude = "lat", longitude = "long", altitude = "alt",
#           metadata = stations_niger)

IDEMSInternational/cdms.products documentation built on July 7, 2023, 10:13 a.m.