replicate | control | treatment |
---|---|---|
1 | 5.496714 | 5.597440 |
2 | 4.861736 | 9.278417 |
3 | 5.647689 | 6.479754 |
4 | 6.523030 | 4.913434 |
5 | 4.765847 | 7.733817 |
6 | 4.765863 | 4.668735 |
Activity 3: Coral colony growth
For this activity, you will repeat all the steps in activity 2 but using a different dataset, variables, and research question. Make sure that you have copied, run, and reviewed all code in activity 2 before starting this activity.
Here you are looking at coral colony growth measurements from the experiment described below. You will make a new R script 1, follow the same general procedure used in activity 2(the great white shark tutorial), and answer the underlined questions.
Research Context: Imagine researchers are studying the effect of a new marine conservation method on the growth of coral colonies. They set up two sites:
Control Site: Where no conservation methods are applied.
Treatment Site: Where the new conservation method is implemented.
After 6 months, they measure the growth (in centimeters) of randomly chosen coral colonies from both sites. They do this by subtracting the length (in cm) at the beginning of the time period ( \(Length_{start}\) ) from the length at the end (in cm) of the 6 month time period (\(Length_{end}\)):
\[Growth = Length_{end} - Length_{start}\]
Here are the first few rows of the data :
The control
column contains \(Growth\) (in cm) of 30 coral colonies from the control site, while the treatment
column contains \(Growth\) (in cm) of 30 coral colonies from the treatment site (where the new conservation method was applied).
Initial Setup
- i. Open a new script and make a header: At the top of your R script, include a header with your name, the date, and a brief description of the analysis.
###########################
# Lab Activity Week 4:
# Author:
# Date:
###########################
- ii. Setting the Working Directory: Set the working directory to where your dataset is located, and where you want to save your scripts and outputs. It is helpful to save these scripts all together so you can come back to them.
setwd("set/your/working/directory/here")
-
iii. Loading Packages: Load the necessary packages (e.g.,
dplyr, ggplot2
) for the exercise. Make sure you have these installed (install.packages()
)
1. Load your data (rename YOUR_DATA_WIDE
!!) and describe it (complete the sentence: “In this data, each row contains ________________”).
2. Melt (using pivot_longer()
) your data into long format - I provided the column names. Look at YOUR_DATA_WIDE
and YOUR_DATA_LONG
. and look up ?pivot_longer
.
Describe what pivot_longer()
did to this data one or two sentences.
YOUR_DATA_LONG <- YOUR_DATA_WIDE %>%
pivot_longer(cols = c(control, treatment),
names_to = "group",
values_to = "growth")
# look at your data:
head(YOUR_DATA_LONG)
3. Summarise your data: Calculate mean and standard error of the mean (SEM) growth of each group
4. Visualize your data using a histogram
Do these data look normally distributed?
5. Perform a t-test
To test if there’s a significant difference in the coral colony growth between treatment and control sites. Use an independent two-sample t-test.
t_result <-
t.test(SOMETHING ~ SOMETHING,
data = SOMETHING,
var.equal = TRUE)
t_result
6. Interpret the Results
What are your null and alternative hypotheses? do you reject the null hypothesis? at what significance level? report your means ± SEM . Draw conclusions about the significance of the difference in coral colony growth between treatment and control group. Think back to the experiment, and why it was done; did the conservation method work? Consider the assumptions of the t-test and evaluate whether they hold for this dataset and what else you might need to do to fully test those assumptions.
remember to add proper heading, set your working directory, and load all necessary libraries at top of your script.↩︎