Skip to contents

This function tidies and processes temperature, relative humidity, and date data from a given dataset.

It filters out rows with missing date values, renames columns, converts temperature and humidity to numeric types, and groups the data by site, sensor, and date. The function also pads the data to ensure hourly intervals.

  • Filters out rows with missing dates

  • Renames columns for consistency

  • Converts temperature and relative humidity to numeric

  • Rounds dates down to the nearest hour

  • Calculates hourly averages for temperature and relative humidity

  • Pads the data to ensure hourly intervals

  • Filters out implausible temperature and humidity values

Usage

tidy_TRHdata(
  mydata,
  Site_col = "Site",
  Sensor_col = "Sensor",
  Date_col = "Date",
  Temp_col = "Temp",
  RH_col = "RH"
)

Arguments

mydata

A data frame containing the raw TRH data. This should include columns for site, sensor, date, temperature, and relative humidity.

Site_col

A string specifying the name of the column in `mydata` that contains location information. Default is "Site".

Sensor_col

A string specifying the name of the column in `mydata` that contains sensor information. Default is "Sensor".

Date_col

A string specifying the name of the column in `mydata` that contains date information. Default is "Date".

Temp_col

A string specifying the name of the column in `mydata` that contains temperature data. Default is "Temp".

RH_col

A string specifying the name of the column in `mydata` that contains relative humidity data. Default is "RH".

Value

A tidy data frame containing processed TRH data with columns for Site, Sensor, Date (floored to the nearest hour), Temperature (mean values), and Relative Humidity (mean values).

Examples

if (FALSE) { # \dontrun{
# Example usage:
mydata <- read.csv("path/to/your/data.csv")
tidy_data <- tidy_TRHdata(mydata,
                           Site_col = "RECEIVER",
                           Sensor_col = "TRANSMITTER",
                           Date_col = "DATE",
                           Temp_col = "TEMPERATURE",
                           RH_col = "HUMIDITY")

# View the tidy data
head(tidy_data)
} # }