export_climdex: Export data in the format for RClimDex

View source: R/export_climdex.R

export_climdexR Documentation

Export data in the format for RClimDex

Description

export_climdex rearranges a data frame using prepare_climdex to a format suitable for use in RClimDex. The data frame is then written to a file or connection.

Usage

export_climdex(
  data,
  prcp,
  tmax,
  tmin,
  date = NULL,
  year = NULL,
  month = NULL,
  day = NULL,
  file_type = c("csv", "txt"),
  file_path = paste0("climdex-", Sys.Date()),
  ...
)

Arguments

data

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

prcp

character(1) Name of the precipitation/rainfall column in data.

tmax

character(1) Name of the maximum temperature column in data.

tmin

character(1) Name of the minimum temperature column in data.

date

character(1) Name of the date column in data. This is only needed if year, month, and day are not specified.

year

character(1) Name of the year column in data. If NULL it will be created using lubridate::year(data[[date]]).

month

character(1) Name of the month column in data. If NULL it will be created using lubridate::month(data[[date]]).

day

character(1) Name of the day of the month column in data. If NULL it will be created using lubridate::day(data[[date]]).

file_type

character(1) A character specifying the file type to export as, either "csv" or '"txt".

file_path

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

...

Other parameters passed to write.table()

Value

Invisibly returns the file path of the saved data

Examples

# Export data to climdex
# NOT RUN:
# export_climdex(data = daily_niger, date = "date", prcp = "rain", tmax = "tmax", tmin = "tmin")

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