Multiple tables
Most Carob scripts produce a single “wide” data.frame d where each row is an experimental unit (plot, treatment, or household) and each column is a standardized variable. However, some datasets contain observations that do not fit into one row per unit without losing information.
carobiner::write_files() supports three additional tables alongside d:
carobiner::write_files(path, meta, d, long = dlong, wth = w, var_meta = vmeta)
Only include the extra arguments that apply to your dataset.
Repeated measurements (long)
When variables are measured more than once per experimental unit — for example, plant height or LAI recorded on multiple dates, weed cover per species across growth stages, or split fertilizer applications — do not drop earlier dates or aggregate them into a single summary value. Keep the plot-level variables in d and put the repeated observations in a separate data.frame passed to long.
Every long table needs:
A key that links back to
d:record_id,plot_id,trial_id, orhhid.A distinguishing variable so each row is uniquely identified, such as
date,DAP/DAE(days after planting/emergence),order, orrep.
dlong <- data.frame(
plot_id = r$plot_id,
DAP = as.integer(r$DAS),
weed_cover = r$WeedCover,
LAI = r$LAI
)
carobiner::write_files(path, meta, d, long = dlong)
write_files() automatically attaches dataset_id and saves the table as <dataset_id>_long.csv.
Weather observations (wth)
When an experimental dataset also includes daily or hourly weather records, do not average them into d. Store them in a separate data.frame using terminag weather variables (such as date, tmin, tmax, prec, srad, rhum, wspd) together with station/location identifiers (station_id, longitude, latitude, elevation), and pass it via wth:
w <- data.frame(
station_id = r_wth$station,
date = as.character(as.Date(r_wth$date)),
tmin = r_wth$tmin,
tmax = r_wth$tmax,
prec = r_wth$rain,
longitude = 31.8388,
latitude = -17.6500
)
carobiner::write_files(path, meta, d, wth = w)
If the raw weather data are sub-hourly (e.g. 5-, 15-, or 30-minute intervals), aggregate them to hourly timesteps using carobiner::get_function("aggregate_hourly", path, "weather"). write_files() saves the weather table as <dataset_id>_wth.csv.
Variable metadata (var_meta)
When a dataset documents laboratory or measurement methods for specific variables — most commonly soil extraction methods such as Mehlich-3, Olsen, or Bray-1 — record them in a small data.frame with variable and method columns and pass it via var_meta:
soilmeta <- data.frame(
variable = c("soil_P", "soil_K", "soil_Ca", "soil_Mg"),
method = "Mehlich3"
)
carobiner::write_files(path, meta, d, var_meta = soilmeta)
write_files() saves this table as <dataset_id>_meta_variable.csv.
Intercrops
Intercropping trials do not need a separate table, but they do need care in d. When yields or other crop-specific measurements (such as seed rate, planting date, or ground cover) are reported separately for each component crop in a plot, represent each component crop as its own row sharing the same plot_id:
Set
cropto the component crop for that row andintercropsto the companion crop(s).Give each row its own
record_idso anylongobservations attach to the right crop.Use standard variable names (
yield,seed_rate,planting_date) on each crop’s row rather than creatingintercrop_*columns.