Learn R Programming

tidyweather (version 0.2.0)

write_weather: Write weather data to file

Description

Exports weather records to a file in the specified format. Currently supports APSIM format for agricultural modeling applications.

Usage

write_weather(records, file, format = "APSIM", overwrite = FALSE)

Value

Invisibly returns the file path of the written file

Arguments

records

A data frame containing weather data with columns for date, temperature, precipitation, and other meteorological variables

file

Character string specifying the output file path

format

Character string specifying the output format. Currently supports "APSIM" (default)

overwrite

Logical indicating whether to overwrite existing files. Default is FALSE

Examples

Run this code
# Read sample weather data from package
file <- system.file("extdata/ppd_72150.met", package = "tidyweather")
records <- read_weather(file)

# Write to temporary file
temp_file <- tempfile(fileext = ".met")

# Write to APSIM format
write_weather(records, temp_file, format = "APSIM")

# Overwrite existing file
write_weather(records, temp_file, format = "APSIM", overwrite = TRUE)

Run the code above in your browser using DataLab