prepare_geoclim_month: Prepare monthly data in GeoCLIM format

View source: R/prepare_geoclim_month.R

prepare_geoclim_monthR Documentation

Prepare monthly data in GeoCLIM format

Description

prepare_geoclim_month takes a data frame that is in monthly format. This data is then rearranged to a format suitable for use in GeoCLIM. This data frame can be rearranged and exported to a file or connection with export_geoclim_month.

Usage

prepare_geoclim_month(
  data,
  date_time = NULL,
  year = NULL,
  month = NULL,
  element,
  station_id,
  latitude,
  longitude,
  metadata = NULL,
  join_by = NULL,
  add_cols = NULL
)

Arguments

data

data.frame The data.frame to calculate from.

date_time

Date The name of the date column in data.

year

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

month

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

element

character(1) The name of the element column in data to apply the function to.

station_id

character(1) The name of the station column in metadata, or data if metadata = NULL.

latitude

character(1) The name of the latitude column in metadata, or data if metadata = NULL.

longitude

character(1) The name of the longitude column in metadata, or data if metadata = NULL.

metadata

data.frame The metadata data.frame to calculate from.

join_by

character The variable(s) to merge the data and metadata data frames.

add_cols

character Names of additional metadata columns that should be included in the output

Value

A data.frame formatted for use in GeoCLIM

Examples

# Calculate monthly summaries for the rainfall column
summary_data <- daily_niger %>% dplyr::group_by(year, month, station_name) %>%
     dplyr::summarise(mean_rain = mean(rain))
prepare_geoclim_month(data = summary_data, year = "year", month = "month",
                   station_id = "station_name",
                   element = "mean_rain", metadata = stations_niger,
                   join_by = "station_name",
                   latitude = "lat", longitude = "long")

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