View source: R/climate_functions.R
| read.climate | R Documentation |
A robust climate-data reader designed to be as flexible as read.dendrometer(). It accepts data frames and common file formats, auto-detects separators and decimal marks, parses many datetime formats, supports Excel serial dates, supports separate date + time columns, detects the time column automatically, sorts timestamps, removes duplicates, converts numeric-like climate variables, and returns a standardized tibble with a POSIXct TIME column.
read.climate(
x,
time_col = NULL,
vars = NULL,
sep = NULL,
dec = NULL,
header = TRUE,
sheet = 1,
tz = "UTC",
drop_duplicate_time = TRUE,
min_time_success = 0.6,
verbose = TRUE,
datetime_col = NULL,
date_col = NULL,
range = NULL,
na = c("", "NA", "NaN", "nan", "null", "NULL", "-9999", "-999", "N/A"),
assume_midnight = TRUE,
orders = NULL,
excel_dates = c("auto", "none", "1900", "1904"),
drop_empty_cols = TRUE,
trim_names = TRUE,
detect_resolution = FALSE,
return_report = FALSE,
quiet = !verbose
)
x |
A data frame or path to a file. Supported file extensions are csv, txt, tsv, tab, dat, xls, xlsx, rds, rda, and RData. |
time_col |
Backward-compatible explicit time/datetime column name or index. If date_col is also supplied, this is treated as the time-of-day column. |
vars |
Optional character vector of climate variables to keep. |
sep |
Optional field separator for text files. If NULL, it is auto-detected. |
dec |
Optional decimal mark for text files. If NULL, it is auto-detected. |
header |
Logical; passed to text-file readers. |
sheet |
Sheet name or index for Excel files. |
tz |
Time zone for parsed timestamps. |
drop_duplicate_time |
Logical; if TRUE, duplicated timestamps are removed. |
min_time_success |
Minimum parsing success proportion for automatic time detection. |
verbose |
Logical; print an import summary. |
datetime_col |
Optional explicit datetime column name or index. Prefer this when the file has one combined timestamp column. |
date_col |
Optional explicit date column name or index. Can be combined with time_col, or parsed alone with midnight appended when assume_midnight = TRUE. |
range |
Optional Excel cell range. |
na |
Strings to treat as missing values. |
assume_midnight |
Logical; if TRUE, date-only values are assigned 00:00:00. |
orders |
Optional lubridate parse_date_time() orders. |
excel_dates |
One of auto, none, 1900, or 1904. |
drop_empty_cols |
Logical; if TRUE, columns that are completely empty are removed. |
trim_names |
Logical; if TRUE, trim whitespace from column names. |
detect_resolution |
Logical; if TRUE, attach simple time-resolution diagnostics. |
return_report |
Logical; if TRUE, return list(data = ..., report = ...). |
quiet |
Logical; suppress messages. By default this is the inverse of verbose. |
A tibble of class dm_clim with TIME in the first column. An import report is attached as attr(x, "import_report").
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.