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:

  1. Control Site: Where no conservation methods are applied.

  2. 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 :

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

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

###########################
# Lab Activity Week 4: 
# Author:  
# Date: 
###########################
setwd("set/your/working/directory/here")

1. Load your data (rename YOUR_DATA_WIDE !!) and describe it (complete the sentence: “In this data, each row contains ________________”).

YOUR_DATA_WIDE <- read.csv("https://raw.githubusercontent.com/laurenkolinger/MES503data/main/week4/coralGrowth.csv")

#look at your data
head(YOUR_DATA_WIDE)

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

YOUR_DATA_LONG_SUMMARY <- YOUR_DATA_LONG %>%
  group_by(GROUPINGCOLUMN) %>%
  summarise(
    MEAN_VALUE  = mean(VALUECOLUMN),
    SEM_VALUE = sd(VALUECOLUMN) / sqrt(length(VALUECOLUMN))
  )

# look at your data: 
YOUR_DATA_LONG_SUMMARY

4. Visualize your data using a histogram

Do these data look normally distributed?

ggplot(YOUR_DATA_LONG,
       aes(x = VALUECOLUMN, group = GROUPINGCOLUMN, fill = GROUPINGCOLUMN),
       alpha = 0.5) +
  geom_histogram(binwidth = 0.5, position = "identity", alpha=0.5) +
  xlab("X AXIS TITLE") +
  ylab("Y AXIS TITLE ") +
  ggtitle("TITLE/CAPTION")

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.


  1. remember to add proper heading, set your working directory, and load all necessary libraries at top of your script.↩︎