load packages and data

calculate summary statistics

CT_summ <- CT_raw %>%             # assign summary statistics to a new data frame
    group_by(
        Concentration, Day) %>%   # group data by G418 concentration and day
    summarize(                    # create new data frame by summarizing grouped data
        Mean = mean(Confluence),  # calculate the average confluence
        Stdev = sd(Confluence),   # calculate the standard deviation
        Low_CI = Mean - 2*Stdev,  # calculate the low confidence interval
        High_CI = Mean + 2*Stdev, # calculate the high confidence interval
    )
## `summarise()` has grouped output by 'Concentration'. You can override using the
## `.groups` argument.

make a line plot showing each treatment’s mean confluence over time

ggplot(                                # create a plot using ggplot2
    data = CT_summ,                    # use summarized confluence data
    aes(                               # set plot aesthetics
        x = Day,                       # x-axis = time point (day)
        y = Mean*100,                  # y-axis = mean confluence at that time point; *100 for %
        color = factor(Concentration)) # groups data by concentration 
    ) + 
    geom_line() +                # add line geometries to the plot
    geom_errorbar(               # add error bars to the plot
        aes(                     # set error bar aesthetics 
            ymin = Low_CI*100,   # assigns low confidence interval to the error bars; *100 for %
            ymax = High_CI*100), # assigns high confidence interval to the error bars; *100 for %
        width = 0.2) +           # set the thickness of the error bars
    geom_point(                  # adds dots for days 0, 3, 5, and 7 for each concentration
        size = 3                 # set dot sizes
    ) +   
    scale_x_continuous(breaks = seq(0, 7, by = 1)) +    # x-axis tick mark values
    scale_y_continuous(breaks = seq(0, 100, by = 20)) + # y-axis tick mark values
    labs(
        x = "Time (days)",              # label x-axis
        y = "Mean Confluence (%)",      # label y-axis
        color = "Concentration (µg/ml)" # legend title
        ) +
    theme(                                     # change theme elements
        axis.title = element_text(size = 20),  # x and y-axis text size
        axis.text = element_text(size = 16),   # x and y tick mark text size
        legend.text = element_text(size = 16), # legend text size
        legend.title = element_text(size = 20) # legend title size
    )