gdd_read: Read Insect Developmental Data from a Folder or a File

View source: R/gdd_read.R

gdd_readR Documentation

Read Insect Developmental Data from a Folder or a File

Description

Reads constant-temperature development data in long format (one row per observation, with a temperature column and a duration column; optional grouping columns such as life stage). The input may be:

  • a single csv file (delimiter auto-detected),

  • a single xlsx/xls file (via the 'readxl' package),

  • a folder containing csv/xlsx files (batch mode), e.g. one file per temperature or per stage; the files are combined and the source file name is kept in a source_file column.

Usage

gdd_read(
  path,
  encoding = "UTF-8",
  header = TRUE,
  temp_from_file = FALSE,
  pattern = "\\.(csv|xlsx|xls)$"
)

Arguments

path

Path to a csv/xlsx file or to a folder (batch mode).

encoding

Text encoding of csv files, default "UTF-8". Use "GBK" for csv files saved from Chinese 'Excel' on 'Windows'.

header

Logical; whether the file(s) contain a header row. Default TRUE.

temp_from_file

Logical (batch mode only); if TRUE, the file name (extension stripped) is converted to a number and written to the temp column — convenient when one file per temperature is named e.g. "25.csv". Default FALSE.

pattern

Regular expression selecting the files in batch mode; default: csv / xlsx / xls.

Value

A data.frame (single file), or the combined data.frame with an extra source_file column (folder input).

See Also

check_path_type (path handling), gdd_check, gdd_calc

Examples

# Single csv file shipped with the package (inst/extdata)
f <- system.file("extdata", "gdd_example.csv", package = "insectecol")
df <- gdd_read(f)
head(df)

# Batch mode: one csv per temperature, temperature from the file names
d <- system.file("extdata", "gdd_batch", package = "insectecol")
df2 <- gdd_read(d, temp_from_file = TRUE)
head(df2)

insectecol documentation built on Oct. 5, 2026, 5:08 p.m.