This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.
plot(cars)
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).
#The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.
# Load rmarkdown package
library(rmarkdown)
# Load knitr package
library(knitr)
# Load tidyverse package
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.0 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
data(CO2)
str(CO2)
## Classes 'nfnGroupedData', 'nfGroupedData', 'groupedData' and 'data.frame': 84 obs. of 5 variables:
## $ Plant : Ord.factor w/ 12 levels "Qn1"<"Qn2"<"Qn3"<..: 1 1 1 1 1 1 1 2 2 2 ...
## $ Type : Factor w/ 2 levels "Quebec","Mississippi": 1 1 1 1 1 1 1 1 1 1 ...
## $ Treatment: Factor w/ 2 levels "nonchilled","chilled": 1 1 1 1 1 1 1 1 1 1 ...
## $ conc : num 95 175 250 350 500 675 1000 95 175 250 ...
## $ uptake : num 16 30.4 34.8 37.2 35.3 39.2 39.7 13.6 27.3 37.1 ...
## - attr(*, "formula")=Class 'formula' language uptake ~ conc | Plant
## .. ..- attr(*, ".Environment")=<environment: R_EmptyEnv>
## - attr(*, "outer")=Class 'formula' language ~Treatment * Type
## .. ..- attr(*, ".Environment")=<environment: R_EmptyEnv>
## - attr(*, "labels")=List of 2
## ..$ x: chr "Ambient carbon dioxide concentration"
## ..$ y: chr "CO2 uptake rate"
## - attr(*, "units")=List of 2
## ..$ x: chr "(uL/L)"
## ..$ y: chr "(umol/m^2 s)"
summary(CO2)
## Plant Type Treatment conc uptake
## Qn1 : 7 Quebec :42 nonchilled:42 Min. : 95 Min. : 7.70
## Qn2 : 7 Mississippi:42 chilled :42 1st Qu.: 175 1st Qu.:17.90
## Qn3 : 7 Median : 350 Median :28.30
## Qc1 : 7 Mean : 435 Mean :27.21
## Qc3 : 7 3rd Qu.: 675 3rd Qu.:37.12
## Qc2 : 7 Max. :1000 Max. :45.50
## (Other):42
Variable <- c("Plant", "Type", "Treatment", "conc", "uptake")
Description <- c("an ordered factor with levels Qn1 < Qn2 <...< Mc1 giving a unique identifier for each plant",
"a factor with levels Quebec Mississippi giving the origin of the plant",
"a factor with levels nonchilled chilled",
"a numeric vector of ambient carbon dioxide concentrations (mL/L)",
"a numeric vector of carbon dioxide uptake rates (umol/m^2 sec)")
metadata <- data.frame(Variable, Description)
kable(metadata)
| Variable | Description |
|---|---|
| Plant | an ordered factor with levels Qn1 < Qn2 <…< Mc1 giving a unique identifier for each plant |
| Type | a factor with levels Quebec Mississippi giving the origin of the plant |
| Treatment | a factor with levels nonchilled chilled |
| conc | a numeric vector of ambient carbon dioxide concentrations (mL/L) |
| uptake | a numeric vector of carbon dioxide uptake rates (umol/m^2 sec) |
metadata2 <- read.csv("metadata.csv")
Description <- c("an ordered factor with levels Qn1 < Qn2 <...< Mc1 giving a unique identifier for each plant",
"a factor with levels Quebec Mississippi giving the origin of the plant",
"a factor with levels nonchilled chilled",
"a numeric vector of ambient carbon dioxide concentrations (mL/L)",
"a numeric vector of carbon dioxide uptake rates (umol/m^2 sec)")
\(v =
V_{max}\frac{[CO_{2}]}{[CO_{2}]_{k}+[CO_{2}]}\)
Even if there is any amount of CO2 available, there is a max uptake of CO2 and a saturation level where no more CO2 can be absorbed.
# Create dataframe of chilled plants from Mississippi
MS_chilled <- CO2[CO2$Type == "Mississippi" & CO2$Treatment == "chilled",]
# Plot relationship for replicate plants
qplot(x = conc,
y = uptake,
data = MS_chilled,
facets = ~Plant,
geom = "line",
xlab = "CO2 Concentration (ppm)",
ylab = "CO2 Uptake Rate (umol/m^2/s)")
## Warning: `qplot()` was deprecated in ggplot2 3.4.0.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
Relationship between ambient CO2 and CO2 uptake for plants collected from Mississippi and chilled prior to measurement
# Create dataframe of chilled plants from Mississippi
QN_chilled <- CO2[CO2$Type == "Quebec" & CO2$Treatment == "chilled",]
# Plot relationship for replicate plants
qplot(x = conc,
y = uptake,
data = QN_chilled,
facets = ~Plant,
geom = "line",
xlab = "CO2 Concentration (ppm)",
ylab = "CO2 Uptake Rate (umol/m^2/s)")
Relationship between ambient CO2 and CO2 uptake for plants collected from Quebec and chilled prior to measurement