Write 3–5 sentences describing the experiment:
The caterpillars were used to test the effects of the saltwater on the plant. The experimenter would water the plants and record the weight of the caterpillars. The other aim is how the saltwater can affect the plant’s growth and response with or without the mechanical damage. It can stunt the growth or induce it.
The response variables are the weight of the caterpillars and the length growth of the plant (specifically the leaf).
The caterpillars used are Manduca sexta caterpillars.
summary (ds)
cat_rgr and leaf_rgr_48:
salt_trtdamage_trtsalt_trt * damage_trtBoxplot for Caterpillar and Salt comparison: boxplot ( ds\(cat_rgr ~ ds\)leaf_rgr_48, main = “Boxplot of Leaf Caterpillar Damage”, ylab = “Caterpillar Length (cm)”, xlab = “Leaf Length (cm)”, col = “red”, border = “blue” )
Boxplot for Leaf Length and damage:
boxplot ( ds\(leaf_rgr_48 ~ ds\)damage_trt, main = “Boxplot of Leaf Salt Treatment”, ylab = “Leaf Length (cm)”, xlab = “Damage Treatment (Group)”, col = “green”, border = “blue” )
Third Boxplot; Later in text.
salt_trt, damage_trt,
and salt_trt:damage_trt.Loading data can be the crux in R. Be sure to save your excel file as a .csv file. When you run the read.csv function be sure that the name of the file is either the same as what I an using or replace the name in ” ” with the file name you used. For example, cat_df=read.csv(“my_file_name.csv”, stringsAsFactors=TRUE). Lastly, be sure to click on the session tab, set workding directory, and choose the directory (i.e., folder) in which you saved your file. Alternatively, you can use the import dataset function but this will cause issues when you try to Knit a final document, so I would avoid this approach.
cat_df = read.csv("example_datasheet.csv", stringsAsFactors = TRUE)
head(cat_df)
## sample_id salt_trt damage_trt leaf_d1_cm leaf_d2_cm leaf_d3_cm cat_initial
## 1 SC1 s ctrl 2.1 2.3 3.22 0.0037
## 2 SC2 s ctrl 2.3 2.5 3.50 0.0042
## 3 SC3 s ctrl 1.6 1.8 2.52 0.0041
## 4 SC4 s ctrl 1.8 2.0 2.80 0.0036
## 5 NSC1 ns ctrl 2.0 2.4 3.36 0.0050
## 6 NSC2 ns ctrl 2.1 2.5 3.50 0.0043
## cat_final cat_rgr leaf_rgr_24 leaf_rgr_48
## 1 0.0039 0.002193489 0.003790491 0.008905084
## 2 0.0044 0.001938334 0.003474234 0.008746955
## 3 0.0043 0.001984502 0.004907626 0.009463652
## 4 0.0038 0.002252801 0.004390021 0.009204849
## 5 0.0090 0.024491111 0.007596732 0.010808204
## 6 0.0083 0.027401687 0.007264724 0.010642200
str(cat_df)
## 'data.frame': 16 obs. of 11 variables:
## $ sample_id : Factor w/ 16 levels "NSC1","NSC2",..: 9 10 11 12 1 2 3 4 13 14 ...
## $ salt_trt : Factor w/ 2 levels "ns","s": 2 2 2 2 1 1 1 1 2 2 ...
## $ damage_trt : Factor w/ 2 levels "ctrl","damage": 1 1 1 1 1 1 1 1 2 2 ...
## $ leaf_d1_cm : num 2.1 2.3 1.6 1.8 2 2.1 2.4 1.9 1.9 2.3 ...
## $ leaf_d2_cm : num 2.3 2.5 1.8 2 2.4 2.5 2.8 2.3 2 2.4 ...
## $ leaf_d3_cm : num 3.22 3.5 2.52 2.8 3.36 3.5 3.92 3.22 2.8 3.36 ...
## $ cat_initial: num 0.0037 0.0042 0.0041 0.0036 0.005 0.0043 0.0021 0.0031 0.0032 0.0039 ...
## $ cat_final : num 0.0039 0.0044 0.0043 0.0038 0.009 0.0083 0.0061 0.0071 0.0032 0.0039 ...
## $ cat_rgr : num 0.00219 0.00194 0.00198 0.00225 0.02449 ...
## $ leaf_rgr_24: num 0.00379 0.00347 0.00491 0.00439 0.0076 ...
## $ leaf_rgr_48: num 0.00891 0.00875 0.00946 0.0092 0.01081 ...
salt_trt and damage_trt are
factors.cat_rgr and leaf_rgr_48 are
numeric.# To fix if they are not factors cat_df$salt_trt<-as.factor(cat_df$salt_trt)
# To fix if they are not numeric cat_df$cat_rgr<-as.numeric(cat_df$cat_rgr)
We will use Rmisc for summary statistics.
library(Rmisc)
cat_rgr)# 1) cat_rgr by salt_trt using boxplot
boxplot (
cat_df$cat_rgr ~ cat_df$salt_trt,
main = "Boxplot of Caterpillar Salt Treatment",
ylab = "Caterpillar Length (cm)",
xlab = "Salt Treatment (Group)",
col = "red",
border = "orange"
)
Task (2–3 sentences): Outliers? Does salt look like it matters?
The outlier is the non-salt because the margins are vague that there is not a precise answer/outcome. Unlike the salt treatment group, there are precise and clear results. The salt matters in terms of caterpillar growth since it stunts their size growth. It is acidic compared to the non-salt, which made them develop more.
# 2) cat_rgr by damage_trt using boxplot
boxplot (
cat_df$cat_rgr ~ cat_df$damage_trt,
main = "Boxplot of Caterpillar Damage Treatment",
ylab = "Caterpillar Length (cm)",
xlab = "Damage Treatment (Group)",
col = "yellow",
border = "brown"
)
Task (2–3 sentences): Outliers? Does damage look like it matters?
The outlier is the control variable fo the damage treatment group. The damage does matter in terms of plant growth because when the caterpillars attacked the plants, the saltwater affected their appetite.
# 3) cat_rgr by salt_trt * damage_trt using boxplot
data.frame(cat_df$cat_rgr)
## cat_df.cat_rgr
## 1 0.002193489
## 2 0.001938334
## 3 0.001984502
## 4 0.002252801
## 5 0.024491111
## 6 0.027401687
## 7 0.044431309
## 8 0.034528861
## 9 0.000000000
## 10 0.000000000
## 11 0.000000000
## 12 0.000000000
## 13 0.001700916
## 14 0.000688721
## 15 0.001141624
## 16 0.000936369
df <- (data.frame (cat_df$cat_rgr))
View (df)
boxplot (
cat_df$cat_rgr ~ cat_df$salt_trt*cat_df$damage_trt,
data = cat_df,
ylab = "Caterpillar Length (cm)",
xlab = "Treatment (group)",
col = "green",
border = "purple"
)
Task (2–3 sentences): Does the pattern suggest an interaction? Explain what you see.
Yes, because the caterpillar length overall decreased as saltwater and damage was being done onto the plant. With just the saltwater and without mechanical damage, it benefited the plant the most. While, both the saltwater and the damage from the caterpillar harmed the plant and stunted the growth a little.
cat_sumstats <- summarySE(data = cat_df, measurevar = “cat_rgr”, groupvars = c(“salt_trt”, “damage_trt”))
cat_sumstats
------------------------------------------------------------------------
## Two-way ANOVA (cat_rgr)
Calculate a two-way anova (i.e., both factors) like we did for the
boxplot above - see the toothgrowth example in class when we talked
about interactions.
``` r
# hint aov(y ~ factor 1 * factor 2, data=....)
# hint, remember to save it as an object and then use summary() for values
aov (cat_sumstats\(cat_rgr ~ cat_sumstats\)salt_trt, data= cat_sumstats)
aov (cat_sumstats\(cat_rgr ~ cat_sumstats\)damage_trt, data= cat_sumstats)
b1 <- (aov (cat_sumstats\(cat_rgr ~ cat_sumstats\)salt_trt, data= cat_sumstats)) b2 <- (aov (cat_sumstats\(cat_rgr ~ cat_sumstats\)damage_trt, data= cat_sumstats))
summary (b1)
summary (b2)
aov (cat_sumstats\(cat_rgr ~ cat_sumstats\)damage_trt*cat_sumstats$salt_trt, data= cat_sumstats)
b3 <- (aov (cat_sumstats\(cat_rgr ~ cat_sumstats\)damage_trt*cat_sumstats$salt_trt, data= cat_sumstats))
summary (b3)
From the ANOVA output, fill in:
##Summary Stats
Task: Create a summary table of cat_rgr
by salt_trt and damage_trt that includes: - N
- mean - sd - se Since we have not used the Rmisc function, I have
provided the code
library(Rmisc)
## Loading required package: lattice
## Loading required package: plyr
# Summary stats (mean + SE) for cat_rgr
cat_sum <- summarySE(cat_df, measurevar = "cat_rgr",
groupvars = c("salt_trt", "damage_trt"))
##Barplot for results section
As before I have given you the code for the barplot
# Create x positions for the 4 bars
x <- barplot(height = cat_sum$cat_rgr,
names.arg = paste(cat_sum$salt_trt, cat_sum$damage_trt, sep = "_"),
ylab = "Mean cat_rgr (± SE)",
ylim = c(0, max(cat_sum$cat_rgr + cat_sum$se) * 1.15))
# Add SE error bars
arrows(x0 = x, y0 = cat_sum$cat_rgr - cat_sum$se,
x1 = x, y1 = cat_sum$cat_rgr + cat_sum$se,
angle = 90, code = 3, length = 0.08)
## Warning in arrows(x0 = x, y0 = cat_sum$cat_rgr - cat_sum$se, x1 = x, y1 =
## cat_sum$cat_rgr + : zero-length arrow is of indeterminate angle and so skipped
Write a short interpretation that answers: - Which effects are significant? - If the interaction is significant (or looks important), what does it mean biologically? - If not, focus on the main effects of each factor.
The damage treatment with the Manduca caterpillars are significant along with the saltwater as treatment. With just the mechanical damage it decreased the caterpillar growth rate. With the saltwater, it also decreased the caterpillar growth rate. Biologically, this means saltwater and adding more herbivores like caterpillars will reduce the impact of those herbivores. It will be more competitive and have an control on plants as well.
leaf_rgr_48)# 1) leaf_rgr_48 by salt_trt boxplots
boxplot (
cat_df$leaf_rgr_48 ~ cat_df$salt_trt,
data= cat_df,
main = "Boxplot of Leaf Salt Treatment in 48Hr",
ylab = "Leaf Length (cm)",
xlab = "Salt Treatment (Group)",
col = "green",
border = "blue"
)
Task (2–3 sentences): Outliers? Does salt look like it matters?
The outliters are not part of the salt treatment, even if it is less abundant than the non-salt treatment. It affects the leaf plant growth with the saltwater treatment, but it is the same length overall.
# 2) leaf_rgr_48 by damage_trt using boxplots
boxplot (
cat_df$leaf_rgr_48 ~ cat_df$damage_trt,
data= cat_df,
main = "Boxplot of Leaf Damage Treatment in 48Hr",
ylab = "Leaf Length (cm)",
xlab = "Salt Treatment (Group)",
col = "pink",
border = "red"
)
Task (2–3 sentences): Outliers? Does damage look like it matters?
Yes, the outlier is the damage treatment compared to the control variable. It decreased the leaf plant growth more than without the damage from the caterpillars.
# 3) leaf_rgr_48 by salt_trt * damage_trt using boxplots
boxplot (
cat_df$leaf_rgr_48 ~ cat_df$damage_trt*cat_df$salt_trt,
data= cat_df,
main = "Boxplot of Leaf Salt and Damage Treatment in 48Hr",
ylab = "Leaf Length (cm)",
xlab = "Salt Treatment (Group) and Damage Treatment (Group)",
col = "pink",
border = "red"
)
Task (2–3 sentences): Does the pattern suggest an interaction? Explain what you see.
The interaction is mostly between the damage and the undamage treatment of the plant with the Manduca caterpillar. It is less significant with the saltwater and regular water treatment, but it is still important showing a clear change.
aov (cat_df$leaf_rgr_48 ~ cat_df$salt_trt, data= cat_df)
## Call:
## aov(formula = cat_df$leaf_rgr_48 ~ cat_df$salt_trt, data = cat_df)
##
## Terms:
## cat_df$salt_trt Residuals
## Sum of Squares 3.522750e-07 2.478644e-05
## Deg. of Freedom 1 14
##
## Residual standard error: 0.001330586
## Estimated effects may be unbalanced
c1 <- (aov(formula = cat_df$leaf_rgr_48 ~ cat_df$salt_trt, data = cat_df))
summary (c1)
## Df Sum Sq Mean Sq F value Pr(>F)
## cat_df$salt_trt 1 3.520e-07 3.523e-07 0.199 0.662
## Residuals 14 2.479e-05 1.771e-06
aov (cat_df$leaf_rgr_48 ~ cat_df$damage_trt, data= cat_df)
## Call:
## aov(formula = cat_df$leaf_rgr_48 ~ cat_df$damage_trt, data = cat_df)
##
## Terms:
## cat_df$damage_trt Residuals
## Sum of Squares 1.709293e-05 8.045787e-06
## Deg. of Freedom 1 14
##
## Residual standard error: 0.0007580891
## Estimated effects may be unbalanced
c2 <- (aov(formula = cat_df$leaf_rgr_48 ~ cat_df$damage_trt, data = cat_df))
summary (c2)
## Df Sum Sq Mean Sq F value Pr(>F)
## cat_df$damage_trt 1 1.709e-05 1.709e-05 29.74 8.5e-05 ***
## Residuals 14 8.046e-06 5.750e-07
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
From the ANOVA output, fill in:
Task: Create a summary table of
leaf_rgr_48 by salt_trt and
damage_trt that includes: - N - mean - sd - se Since we
have not used the Rmisc function, I have provided the code
# Summary stats (mean + SE) for leaf_rgr_48
leaf_sum <- summarySE(cat_df, measurevar = "leaf_rgr_48",
groupvars = c("salt_trt", "damage_trt"))
##Barplot for results section
As before I have given you the code for the barplot
x <- barplot(height = leaf_sum$leaf_rgr_48,
names.arg = paste(leaf_sum$salt_trt, leaf_sum$damage_trt, sep = "_"),
ylab = "Mean leaf_rgr_48 (± SE)",
ylim = c(0, max(leaf_sum$leaf_rgr_48 + leaf_sum$se) * 1.15))
arrows(x0 = x, y0 = leaf_sum$leaf_rgr_48 - leaf_sum$se,
x1 = x, y1 = leaf_sum$leaf_rgr_48 + leaf_sum$se,
angle = 90, code = 3, length = 0.08)
Write a short interpretation that answers: - Which effects are significant? - If the interaction is significant (or looks important), what does it mean biologically? - If not, focus on the main effects.
They are significant, however it is not as drastic as the previous graphs. There are small margins of error for each and each group (ns_ctrl, ns_damage, s_ctrl, and s_damage) are around the 0.006-0.011 range. It is by small significance because the salt controlled variable adn the salt damaged variable are close in terms of values. the non-salt controlled variable has the highest mean leaf growth rate. The lowest is the one near it, the ns_damage, which means the non-salted damaged plant has the least overall growth.
Task (10–14 sentences total): Write a short Results
section that includes: - A sentence describing the design (2×2
factorial) and analysis (two-way ANOVA). - Include the barplot
figures.
- For cat_rgr: report which terms were significant, with
df, F, p. - For leaf_rgr_48: report which terms were
significant, with df, F, p. If there is an interaction: describe the
pattern clearly.
The salt treatment for the caterpillar growth rate is the most significant with a P-value of 0.42. The P-value of damage treatment for the caterpillar growth rate is 0.39. Each with a degree of freedom of 2, The spread of variance, or F-value, is close but the damage treatment was more spread apart (F value= 1.209). The values for the salt treatment is 1.005, meaning it is more precise corresponding with the barplot.
summary (leaf_sum) aov (leaf_sum\(leaf_rgr_48 ~ leaf_sum\)salt_trt, data= leaf_sum) d1 <- (aov (leaf_sum\(leaf_rgr_48 ~ leaf_sum\)salt_trt, data= leaf_sum)) summary (d1)
aov(formula = leaf_sum\(leaf_rgr_48 ~ leaf_sum\)damage_trt, data = leaf_sum) d2 <- (aov(formula = leaf_sum\(leaf_rgr_48 ~ leaf_sum\)damage_trt, data = leaf_sum)) summary (d2)
With the leaf growth rate for 48 hours, the most significant groyp is the salt treatment as well. With a p-value of 0.88, which is the closest to the value of one, it has a F-value of 0.03, meaning the spread of valence is small. It is precise and the most significant. The damage treatment of the leaf growth rate has a p-value of 0.16 and a F-value of 4.89. It is undependable and too vague to use.
End with 1–2 sentences of biological interpretation.
This can impact the biological/ecological world because it can control pest and their population. It makes the caterpillars weaker and less developed than no salt treatment. It can also be used to help us understand the use of saltwater onto plants, since it also made plants weaker and dryer.