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

Notes

Here's the analysis for the second draft of the root figures. Changes that we talked about previously:

  1. Figure 3 is being remade as a combination of old figures 3, 5, and some of 6/7.
  2. Table of 'site', 'date', 'depth_bin', 'biomass', and standard deviation of biomass across depth_bin per given site.
  3. Depth bins: 0-10 cm, 10 - 20cm, etc.
  4. Tabels of both pre- and post- aggregation.
  5. Figure 2 is being remade as old figures 4 and 2. Graph 'relative activity' of grass and Adenostoma using NDVI and E. To do this:
  6. Write/create a sapflow data table that reflects relative sapflow, i.e. just use an index and skip the zeroing.
  7. Methods for this process.

This vignette focuses just on the root stuff.

Analysis

data("SDEF_root_data_raw") # Load raw root data.
data("SDEF_root_ash_weights") # Load ash weight data.
SDEF_data <- SDEF_root_data # Shorten variable name for convenience.
colnames(SDEF_data) <- ifelse(
  colnames(SDEF_data) == "tile", "frame", colnames(SDEF_data)
)

# below is old script
  data.root <- ConvertFrameDepth(data=data.root)
  data.ash <- CalculateCarbonContent(data=data.ash)
  # Frame height 6.75mm, frame width 9.0 mm
  data.root <- CalculateBioDensity(data=data.root, frame.size = c(6.75, 9.0, 0.74), scale="tube")
  data <- data.root
  biomass.convert <- c(0.21, 0.22, 0.31)
  names(biomass.convert) <- c("grass", "shrub", "tree")
  # Calculation section ####
  biovolume <- (pi * ((data$diameter / 2) ^ 2)) * data$length # Units in mm^3
  biovolume <- biovolume / 1000 # Convert mm^3 to cm^3
  convert <- vector(mode="character", length=nrow(data))
  for (i in names(biomass.convert)) {
    convert <- sub(x=data[["veg_type"]], pattern=i,
                   replacement=names(biomass.convert)[which(names(biomass.convert) == i)]
    )
  }
  biomass <- biovolume * biomass.convert[data[["veg_type"]]] # Conversion factor is g per cm^3
  # This will convert units to grams of biomass
  data <- data.frame(data, biovolume, biomass)
  data$real_depth <- data$real_depth * -1
  #plot biomass
  library(ggplot2)
  library(reshape2)
  data_grass <- data[which(data$plot == "grass"), ]
  bio_plot <- ggplot(data_grass, aes(real_depth, biomass))
  bio_plot <- bio_plot + stat_smooth()
  depth_plot <- ggplot(data_grass, aes(date, real_depth))
  depth_plot <- depth_plot + geom_tile(aes(fill = biomass))
  if (scale == "root") {
    message("Returning root-scale data... Done")
    return(data)
  }
  biodensity <- data.frame(matrix(ncol=6, nrow=0))
  colnames(biodensity) <- c("tube", "date", "sum_biovolume", "sum_biomass", "mean_depth",
                            "tube_biodensity")

  # end

Other notes from the vignette default style:

Figures

The figure sizes have been customised so that you can easily put two images side-by-side.

plot(1:10)
plot(10:1)

You can enable figure captions by fig_caption: yes in YAML:

output:
  rmarkdown::html_vignette:
    fig_caption: yes

Then you can use the chunk option fig.cap = "Your figure caption." in knitr.

More Examples

You can write math expressions, e.g. $Y = X\beta + \epsilon$, footnotes^[A footnote here.], and tables, e.g. using knitr::kable().

knitr::kable(head(mtcars, 10))

Also a quote using >:

"He who gives up [code] safety for [code] speed deserves neither." (via)



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