knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

This is the pre-process code for the SDEF_roots_pre_aggregation dataset.

# Analyze root data, make table of 'site', 'date', 'depth_bin', 'biomass',
# and standard deviation of depth_bina across site
library(SDEF.analysis)
data("SDEF_root_data_raw") # Load raw root data.
root_data <- SDEF_root_data_raw # Shorten variable name for convenience.
colnames(root_data) <- ifelse(
  colnames(root_data) == "tile", "frame", colnames(root_data)
) # Change column name to 'frame', that's what works with frame depth function
root_data <- SDEF.analysis::ConvertFrameDepth(data = root_data)
# ConvertFrameDepth adds a real_depth column, which is depth of the
# observed root in centimeters below ground level.
root_data <- root_data[-which(root_data[["real_depth"]] > 40), ]
# Only 4 observations for depth bin 5 - dropped those.
# Add site - first 3 tubes are Adenostoma plots, other 3 are grass
site <- root_data[["tube"]]
site <- ifelse(site < 4, "adenostoma", site)
site <- ifelse(site == "adenostoma", site, "grass")
root_data <- data.frame(site, root_data)
# Add depth-bin: 0-9.99 (1), 10-19.99 (2), 20-29.99 (3),
# 30-39.99 (4), 40-49.99 (5), 50-59.99 (6).
depth_bin <- rep(4, nrow(root_data))
#depth_bin[which(root_data[["real_depth"]] < 50)] <- 5
#depth_bin[which(root_data[["real_depth"]] < 40)] <- 4
depth_bin[which(root_data[["real_depth"]] < 30)] <- 3
depth_bin[which(root_data[["real_depth"]] < 20)] <- 2
depth_bin[which(root_data[["real_depth"]] < 10)] <- 1
root_data <- data.frame(root_data, depth_bin)
SDEF_roots_pre_process <- root_data
#devtools::use_data(SDEF_roots_pre_process)

End script!



bmcnellis/SDEF.analysis documentation built on June 4, 2019, 10 a.m.