General project set-up

# Libraries
  library(reshape2)
  library(tidyverse)

# Graphs

theme_set (theme_classic() + theme(panel.grid.major = element_blank(),
                              panel.grid.minor = element_blank(), 
                              axis.line = element_line(colour = "black"),
                              legend.position="none",
                              axis.text.x = element_text(angle = 90, vjust = 0.5),
                              plot.title = element_text(size=12, face="bold"),
                              #panel.border = element_rect(colour = "black", fill=NA, size=1)
                              panel.border = element_blank()
                              ))

    
# Data    
  # Fragment list
  #CurrentFragments<-read.csv("8.Metadata/Frag_assignments.csv", header = T)

  # Collection information
  #Location<-read.csv("8.Metadata/Genotypes.csv", header = T)

Meta data

# Treatment Info
  Treatment<-read.csv("Data/Treatments.csv")
  #duplicated(Treatment$Tag)
  Treatment<-Treatment[!duplicated(Treatment$Tag), ]
  #duplicated(Tags$Tag)
  summary(Treatment)
##       Tag          Genotype        Nutrients       Disease   
##  201    :  1   Elkhorn : 28   Ambient   :125   Ambient :  1  
##  202    :  1   Kelsey-1: 26   Dead      :  1   Dead    :  1  
##  204    :  1   U44     : 26   Experiment:  1   Extra   :  6  
##  205    :  1   FM19    : 25   Extra     :  6   Pathogen:134  
##  207    :  1   FM6     : 25   NH4       :127   Placebo :118  
##  208    :  1   Acerv2  : 24                                  
##  (Other):254   (Other) :106                                  
##       Available  
##            :  0  
##  Dead      :  4  
##  Experiment:249  
##  Extra?    :  6  
##  Placebo   :  1  
##                  
## 
# Tags weight
  Tags<-read.csv("Data/Tags_W.csv")
  #duplicated(Tags$Tag)
  Tags<-Tags[!duplicated(Tags$Tag), ]
  #duplicated(Tags$Tag)
  summary(Tags)
##  T_Type       Tag           T_AW            T_BW        Temperature   
##  B:200   201    :  1   Min.   :10.01   Min.   :1.393   Min.   :23.33  
##  S: 72   202    :  1   1st Qu.:10.16   1st Qu.:1.448   1st Qu.:26.19  
##          204    :  1   Median :16.26   Median :2.285   Median :26.36  
##          205    :  1   Mean   :14.65   Mean   :2.061   Mean   :26.16  
##          207    :  1   3rd Qu.:16.32   3rd Qu.:2.298   3rd Qu.:26.82  
##          208    :  1   Max.   :16.48   Max.   :2.333   Max.   :27.88  
##          (Other):266                                                  
##     Salinity          X      
##  Min.   :33.2          :271  
##  1st Qu.:33.2   Guessed:  1  
##  Median :33.2                
##  Mean   :33.2                
##  3rd Qu.:33.2                
##  Max.   :33.2                
## 
  Tags$SW_den<-(999.842594+0.06793952*(Tags$Temperature)-0.00909529*(Tags$Temp)^2+0.0001001685*
    (Tags$Temperature)^3-0.000001120083*(Tags$Temperature)^4+0.000000006536332*(Tags$Temp)^5+(0.824493-0.0040899*
    (Tags$Temperature)+0.000076438*(Tags$Temperature)^2-0.00000082467*(Tags$Temperature)^3+0.0000000053875*
    (Tags$Temperature)^4)*(Tags$Salinity)+(-0.00572466+0.00010227*(Tags$Temperature)-0.0000016546*
    (Tags$Temperature)^2)* (Tags$Salinity)^1.5+0.00048314*(Tags$Salinity)^2)*0.001
  
   #Tags$Estimated_Density<-(-Tags$SW_den/((Tags$T_BW/Tags$T_AW)-1))
   
  Tags %>%
      group_by(T_Type) %>%
      summarise_at(vars(T_AW, T_BW), funs(mean(., na.rm=TRUE)))

BW data

# 1. BW data
  BW_Tall<-read.csv("Data/BW_ Long_data.csv")
  
  #BW_Tall$Estimated.W.density[BW_Tall$Estimated.W.density == "#VALUE!" ] <-NA
  #BW_Tall$Estimated.W.density<-as.numeric(as.character(BW_Tall$Estimated.W.density))
  
  #BW_Tall$Estimated_AW [BW_Tall$Estimated_AW == "#VALUE!" ] <-NA
  #BW_Tall$Estimated_AW<-as.numeric(as.character(BW_Tall$Estimated_AW))
  
# 2. Data clean-up an types: 
  
  # Variable types 
    #BW_Tall$Time <- as.factor(BW_Tall$Time)
    #BW_Tall$Time<-as.numeric(BW_Tall$Time)
    BW_Tall$Date<-as.Date(BW_Tall$Date, "%Y-%m-%d")
    BW_Tall$Day<-(as.numeric(BW_Tall$Date)-18486)
  
  # Remove-unused data    
    #Extras <- BW_Tall[which (BW_Tall$Nutrients=="Extra"), ]
    #BW_Tall <- droplevels(BW_Tall[!rownames(BW_Tall) %in%
    #                                   rownames(Extras), ])

# 3. Merge with treatments
    BW_Tall<-plyr::join(BW_Tall, Treatment, by = "Tag", 
                type = "left", match = "all")

    BW_Tall<-plyr::join(BW_Tall, Tags, by = "Tag", 
                type = "left", match = "all")
    
    BW_Tall$Nutrients<-factor(BW_Tall$Nutrients, 
                             levels= c("Ambient", "NH4"), ordered=TRUE)
    BW_Tall$Disease<-factor(BW_Tall$Disease, 
                             levels= c("Placebo", "Pathogen"), ordered=TRUE)

# 4. Replicates
    BW_Tall$Tank<-factor(BW_Tall$Tank, ordered=FALSE)
    BW_Tall$Genotype<-factor(BW_Tall$Genotype, ordered=FALSE)

    summary(BW_Tall)
##       Tag           Tank          Date                  BW        
##  201    :  3   3      : 94   Min.   :2020-08-12   Min.   : 2.686  
##  202    :  3   1      : 93   1st Qu.:2020-08-12   1st Qu.: 3.897  
##  204    :  3   2      : 93   Median :2020-08-21   Median : 4.604  
##  205    :  3   4      : 93   Mean   :2020-08-22   Mean   : 5.152  
##  207    :  3   6      : 93   3rd Qu.:2020-09-04   3rd Qu.: 6.145  
##  208    :  3   7      : 93   Max.   :2020-09-04   Max.   :11.950  
##  (Other):742   (Other):201                        NA's   :1       
##       Temp           Sal                       Notes          Day       
##  Min.   :27.0   Min.   :32.10                     :744   Min.   : 0.00  
##  1st Qu.:27.3   1st Qu.:32.50   New               :  5   1st Qu.: 0.00  
##  Median :27.6   Median :34.30   Batch 2           :  1   Median : 9.00  
##  Mean   :27.7   Mean   :33.61   dead              :  1   Mean   :10.66  
##  3rd Qu.:28.0   3rd Qu.:34.50   Dead              :  1   3rd Qu.:23.00  
##  Max.   :29.1   Max.   :34.70   maybe broke at top:  1   Max.   :23.00  
##  NA's   :1      NA's   :1       (Other)           :  7                  
##      Genotype     Nutrients       Disease         Available   T_Type 
##  Elkhorn : 80   Ambient:371   Placebo :353             :  0   B:548  
##  Kelsey-1: 74   NH4    :379   Pathogen:397   Dead      : 10   S:212  
##  U44     : 74   NA's   : 10   NA's    : 10   Experiment:742          
##  FM6     : 73                                Extra?    :  8          
##  Acerv2  : 72                                Placebo   :  0          
##  FM14    : 72                                                        
##  (Other) :315                                                        
##       T_AW            T_BW        Temperature       Salinity   
##  Min.   :10.01   Min.   :1.393   Min.   :23.33   Min.   :33.2  
##  1st Qu.:10.14   1st Qu.:1.443   1st Qu.:26.15   1st Qu.:33.2  
##  Median :16.26   Median :2.285   Median :26.34   Median :33.2  
##  Mean   :14.56   Mean   :2.049   Mean   :26.14   Mean   :33.2  
##  3rd Qu.:16.31   3rd Qu.:2.298   3rd Qu.:26.84   3rd Qu.:33.2  
##  Max.   :16.48   Max.   :2.333   Max.   :27.88   Max.   :33.2  
##                                                                
##        X           SW_den     
##         :759   Min.   :1.021  
##  Guessed:  1   1st Qu.:1.021  
##                Median :1.022  
##                Mean   :1.022  
##                3rd Qu.:1.022  
##                Max.   :1.022  
## 

BW

BW calculations

BW.data<-BW_Tall[order(BW_Tall$Tag), ]

# 3. Calculate days bw BW data points
BW.data<-BW.data %>%
  group_by(Tag) %>%
  dplyr::mutate(Days = Day - lag(Day, default = Day[1]))

# 4. Calculate change in BW bw data points
BW.data<-BW.data %>%
  group_by(Tag) %>%
  dplyr::mutate(dBW = BW - lag(BW, default = BW[1]))

BW.data<-BW.data %>%
  group_by(Tag) %>%
  dplyr::mutate(dBW_r = dBW/(Days*lag(BW, default = BW[1])))

BW.data<-BW.data %>%
  group_by(Tag) %>%
  dplyr::mutate(dBW_r = dBW/(Days*lag(BW, default = BW[1])))

BW.data$dBW_r<-BW.data$dBW_r*1000

summary(BW.data)
##       Tag           Tank          Date                  BW        
##  201    :  3   3      : 94   Min.   :2020-08-12   Min.   : 2.686  
##  202    :  3   1      : 93   1st Qu.:2020-08-12   1st Qu.: 3.897  
##  204    :  3   2      : 93   Median :2020-08-21   Median : 4.604  
##  205    :  3   4      : 93   Mean   :2020-08-22   Mean   : 5.152  
##  207    :  3   6      : 93   3rd Qu.:2020-09-04   3rd Qu.: 6.145  
##  208    :  3   7      : 93   Max.   :2020-09-04   Max.   :11.950  
##  (Other):742   (Other):201                        NA's   :1       
##       Temp           Sal                       Notes          Day       
##  Min.   :27.0   Min.   :32.10                     :744   Min.   : 0.00  
##  1st Qu.:27.3   1st Qu.:32.50   New               :  5   1st Qu.: 0.00  
##  Median :27.6   Median :34.30   Batch 2           :  1   Median : 9.00  
##  Mean   :27.7   Mean   :33.61   dead              :  1   Mean   :10.66  
##  3rd Qu.:28.0   3rd Qu.:34.50   Dead              :  1   3rd Qu.:23.00  
##  Max.   :29.1   Max.   :34.70   maybe broke at top:  1   Max.   :23.00  
##  NA's   :1      NA's   :1       (Other)           :  7                  
##      Genotype     Nutrients       Disease         Available   T_Type 
##  Elkhorn : 80   Ambient:371   Placebo :353             :  0   B:548  
##  Kelsey-1: 74   NH4    :379   Pathogen:397   Dead      : 10   S:212  
##  U44     : 74   NA's   : 10   NA's    : 10   Experiment:742          
##  FM6     : 73                                Extra?    :  8          
##  Acerv2  : 72                                Placebo   :  0          
##  FM14    : 72                                                        
##  (Other) :315                                                        
##       T_AW            T_BW        Temperature       Salinity   
##  Min.   :10.01   Min.   :1.393   Min.   :23.33   Min.   :33.2  
##  1st Qu.:10.14   1st Qu.:1.443   1st Qu.:26.15   1st Qu.:33.2  
##  Median :16.26   Median :2.285   Median :26.34   Median :33.2  
##  Mean   :14.56   Mean   :2.049   Mean   :26.14   Mean   :33.2  
##  3rd Qu.:16.31   3rd Qu.:2.298   3rd Qu.:26.84   3rd Qu.:33.2  
##  Max.   :16.48   Max.   :2.333   Max.   :27.88   Max.   :33.2  
##                                                                
##        X           SW_den           Days             dBW          
##         :759   Min.   :1.021   Min.   : 0.000   Min.   :-0.75820  
##  Guessed:  1   1st Qu.:1.021   1st Qu.: 0.000   1st Qu.: 0.00000  
##                Median :1.022   Median : 9.000   Median : 0.04440  
##                Mean   :1.022   Mean   : 7.603   Mean   : 0.06337  
##                3rd Qu.:1.022   3rd Qu.:14.000   3rd Qu.: 0.10390  
##                Max.   :1.022   Max.   :14.000   Max.   : 0.92380  
##                                                 NA's   :1         
##      dBW_r         
##  Min.   :-14.4104  
##  1st Qu.:  0.9473  
##  Median :  1.5155  
##  Mean   :  1.5129  
##  3rd Qu.:  2.0000  
##  Max.   : 10.8928  
##  NA's   :259

BW Exploration

SizeBiasCheck<- ggplot(BW.data, aes (BW, dBW_r, colour=factor(Genotype))) +
  #geom_smooth(method = "lm")+
  geom_jitter(alpha=0.5) + 
  scale_y_continuous(limits = c(0, 5),
                         breaks = seq(0, 6,2),  
                         expand = c(0, 0),
                         name=("AW mg / g*day"))
SizeBiasCheck

Genotype

BW_Genet<- ggplot(BW.data, aes (Genotype, dBW_r, colour=factor(Date))) +
  stat_summary(fun.data = "mean_cl_boot",geom = "errorbar", width = 0.2 )+
  stat_summary(fun.y=mean, geom="line") + 
  geom_jitter(alpha=0.5) +
  scale_y_continuous(limits = c(0, 5),
                         breaks = seq(0, 5,1),  
                         expand = c(0, 0),
                         name=("dBW [mg / g*day]"))+
  theme(legend.position = "bottom")
  
BW_Genet

BW_Genet+ facet_wrap(~Nutrients)

BW_Genet+ facet_wrap(~Disease)

#BW_Genet+ facet_wrap(Nutrients~Disease)

Pre-treatment bias

BW_Bias<- ggplot(BW.data, aes (Genotype, dBW_r, colour=factor(Nutrients))) +
  stat_summary(fun.data = "mean_cl_boot",geom = "errorbar", width = 0.2 )+
  stat_summary(fun.y=mean, geom="line") + 
  geom_jitter(alpha=0.5) +
  scale_y_continuous(limits = c(0, 5),
                         breaks = seq(0, 5,1),  
                         expand = c(0, 0),
                         name=("dBW [mg / g*day]"))
BW_Bias + facet_grid(~Disease)

AW

AW Calculations

# 1. Coral BW
  BW.data$Coral_BW<-(BW.data$BW)-(BW.data$T_BW)

# 2. Water density

  BW.data$SW_den<-(999.842594+0.06793952*(BW.data$Temp)-0.00909529*(BW.data$Temp)^2+0.0001001685*
    (BW.data$Temp)^3-0.000001120083*(BW.data$Temp)^4+0.000000006536332*(BW.data$Temp)^5+(0.824493-0.0040899*
    (BW.data$Temp)+0.000076438*(BW.data$Temp)^2-0.00000082467*(BW.data$Temp)^3+0.0000000053875*(BW.data$Temp)^4)*
    (BW.data$Salinity)+(-0.00572466+0.00010227*(BW.data$Temp)-0.0000016546*(BW.data$Temp)^2)*
    (BW.data$Salinity)^1.5+0.00048314*(BW.data$Salinity)^2)*0.001
    
# 3. Coral air weight
  BW.data$Est_Coral_AW<-(BW.data$Coral_BW)*(1/(1-(BW.data$SW_den)/2.4))
  
# 4. Calculate change in AW bw data points
  BW.data<-BW.data %>%
    dplyr::group_by(Tag) %>%
    dplyr::mutate(dAW = Est_Coral_AW - lag(Est_Coral_AW, default = Est_Coral_AW[1]))

BW.data<-BW.data %>%
  group_by(Tag) %>%
  dplyr::mutate(dAW_r = dAW/(Days*lag(Est_Coral_AW, default = Est_Coral_AW[1])))


BW.data$dAW_r<-BW.data$dAW_r*1000

summary(BW.data)
##       Tag           Tank          Date                  BW        
##  201    :  3   3      : 94   Min.   :2020-08-12   Min.   : 2.686  
##  202    :  3   1      : 93   1st Qu.:2020-08-12   1st Qu.: 3.897  
##  204    :  3   2      : 93   Median :2020-08-21   Median : 4.604  
##  205    :  3   4      : 93   Mean   :2020-08-22   Mean   : 5.152  
##  207    :  3   6      : 93   3rd Qu.:2020-09-04   3rd Qu.: 6.145  
##  208    :  3   7      : 93   Max.   :2020-09-04   Max.   :11.950  
##  (Other):742   (Other):201                        NA's   :1       
##       Temp           Sal                       Notes          Day       
##  Min.   :27.0   Min.   :32.10                     :744   Min.   : 0.00  
##  1st Qu.:27.3   1st Qu.:32.50   New               :  5   1st Qu.: 0.00  
##  Median :27.6   Median :34.30   Batch 2           :  1   Median : 9.00  
##  Mean   :27.7   Mean   :33.61   dead              :  1   Mean   :10.66  
##  3rd Qu.:28.0   3rd Qu.:34.50   Dead              :  1   3rd Qu.:23.00  
##  Max.   :29.1   Max.   :34.70   maybe broke at top:  1   Max.   :23.00  
##  NA's   :1      NA's   :1       (Other)           :  7                  
##      Genotype     Nutrients       Disease         Available   T_Type 
##  Elkhorn : 80   Ambient:371   Placebo :353             :  0   B:548  
##  Kelsey-1: 74   NH4    :379   Pathogen:397   Dead      : 10   S:212  
##  U44     : 74   NA's   : 10   NA's    : 10   Experiment:742          
##  FM6     : 73                                Extra?    :  8          
##  Acerv2  : 72                                Placebo   :  0          
##  FM14    : 72                                                        
##  (Other) :315                                                        
##       T_AW            T_BW        Temperature       Salinity   
##  Min.   :10.01   Min.   :1.393   Min.   :23.33   Min.   :33.2  
##  1st Qu.:10.14   1st Qu.:1.443   1st Qu.:26.15   1st Qu.:33.2  
##  Median :16.26   Median :2.285   Median :26.34   Median :33.2  
##  Mean   :14.56   Mean   :2.049   Mean   :26.14   Mean   :33.2  
##  3rd Qu.:16.31   3rd Qu.:2.298   3rd Qu.:26.84   3rd Qu.:33.2  
##  Max.   :16.48   Max.   :2.333   Max.   :27.88   Max.   :33.2  
##                                                                
##        X           SW_den           Days             dBW          
##         :759   Min.   :1.021   Min.   : 0.000   Min.   :-0.75820  
##  Guessed:  1   1st Qu.:1.021   1st Qu.: 0.000   1st Qu.: 0.00000  
##                Median :1.021   Median : 9.000   Median : 0.04440  
##                Mean   :1.021   Mean   : 7.603   Mean   : 0.06337  
##                3rd Qu.:1.021   3rd Qu.:14.000   3rd Qu.: 0.10390  
##                Max.   :1.021   Max.   :14.000   Max.   : 0.92380  
##                NA's   :1                        NA's   :1         
##      dBW_r             Coral_BW       Est_Coral_AW          dAW         
##  Min.   :-14.4104   Min.   : 0.433   Min.   : 0.7537   Min.   :-1.3199  
##  1st Qu.:  0.9473   1st Qu.: 1.667   1st Qu.: 2.9013   1st Qu.: 0.0000  
##  Median :  1.5155   Median : 2.463   Median : 4.2878   Median : 0.0778  
##  Mean   :  1.5129   Mean   : 3.104   Mean   : 5.4024   Mean   : 0.1106  
##  3rd Qu.:  2.0000   3rd Qu.: 4.036   3rd Qu.: 7.0246   3rd Qu.: 0.1811  
##  Max.   : 10.8928   Max.   :10.517   Max.   :18.3077   Max.   : 1.6120  
##  NA's   :259        NA's   :1        NA's   :1         NA's   :1        
##      dAW_r        
##  Min.   :-37.212  
##  1st Qu.:  1.905  
##  Median :  2.681  
##  Mean   :  2.764  
##  3rd Qu.:  3.568  
##  Max.   : 33.234  
##  NA's   :259

AW Exploration

SizeBiasCheck<- ggplot(BW.data, aes (Est_Coral_AW, dAW_r, colour=factor(Genotype))) +
  #stat_summary(fun.data = "mean_cl_boot",geom = "errorbar", width = 0.2 )+
  #stat_summary(fun.y=mean, geom="line") + 
  geom_jitter(alpha=0.5) + 
  scale_y_continuous(limits = c(0, 10),
                         breaks = seq(0, 10,2),  
                         expand = c(0, 0),
                         name=("dAW [mg / g*day]"))
SizeBiasCheck

Genotype

AW_Genet<- ggplot(BW.data, aes (Genotype, dAW_r, colour=factor(Date))) +
  stat_summary(fun.data = "mean_cl_boot",geom = "errorbar", width = 0.2 )+
  stat_summary(fun.y=mean, geom="line") + 
  theme(legend.position = "none")+
  geom_jitter(alpha=0.5) + 
  scale_y_continuous(limits = c(0, 10),
                         breaks = seq(0, 10,2),  
                         expand = c(0, 0),
                         name=("AW mg / g*day"))+
  theme(legend.position = "bottom")
 
AW_Genet

AW_Genet+ facet_wrap(~Nutrients)

AW_Genet+ facet_wrap(~Disease)

AW_Genet2<- ggplot(BW.data, aes (Date, dAW_r, colour=Genotype)) +
  stat_summary(fun.data = "mean_cl_boot",geom = "errorbar", width = 0.2 )+
  stat_summary(fun.y=mean, geom="line") + 
  theme(legend.position = "none")+
  geom_jitter(shape=21, alpha=0.3)+
  scale_y_continuous(limits = c(0, 10),
                         breaks = seq(0, 10,2),  
                         expand = c(0, 0),
                         name=("AW mg / g*day"))+
  theme(legend.position = "bottom")
 
AW_Genet2

AW_Genet2 + facet_grid(Nutrients~Disease)

BW_Frag<- ggplot(BW.data, aes (Date, dAW_r, group=(Tag),
                                    colour=factor(Genotype))) + 
      geom_line()+
      geom_hline(yintercept = 0, linetype=3)+
      
      #scale_x_continuous(name="Days", 
       #                  breaks = seq(0, 30, by=15)) +
      scale_y_continuous(name="Growth (mg / g d)", 
                         limits = c(-2, 10),
                         breaks = seq(-1, 10, by=1)) +
    
    theme(legend.position="bottom",
        legend.title = element_blank(), 
        strip.background =element_rect(fill=NA)) 
BW_Frag+facet_wrap(~Genotype)

Tank

AW_Tank<- ggplot(BW.data, aes (Tank, dAW_r)) +
  stat_summary(fun.data = "mean_cl_boot",geom = "errorbar", width = 0.2 )+
  stat_summary(fun.y=mean, geom="line") + 
  scale_y_continuous(limits = c(0, 10),
                         breaks = seq(0, 10,2),  
                         expand = c(0, 0),
                         name=("Growth rate (mg / g day)"))+
  geom_jitter(aes(colour=Genotype), shape=21, alpha=0.3)+
  facet_wrap(~Date) +
  theme(legend.position = "bottom")
AW_Tank

AW_Tank+ facet_wrap(Date~Nutrients)

AW_Tank+ facet_wrap(Date~Disease)

Treatments

AW_Disease<- ggplot(BW.data, aes (Disease, dAW_r)) +
  stat_summary(fun.data = "mean_cl_boot",geom = "errorbar", width = 0.2 )+
  stat_summary(fun.y=mean, geom="line") + 
  scale_y_continuous(limits = c(-3, 10),
                         breaks = seq(-3, 10,2),  
                         expand = c(0, 0),
                         name=("Growth rate (mg/g day)"))+
  geom_jitter(aes(colour=Genotype), alpha=0.3)+
  facet_wrap(~Date) +
  theme(legend.position = "bottom")
AW_Disease

AW_Disease + facet_wrap(Date~Nutrients)

AW_Disease + facet_wrap(Date~Disease)

Pre-treatment bias

AW_Bias<- ggplot(BW.data, aes (Genotype, dAW_r, colour=factor(Date), shape=(Nutrients))) +
  stat_summary(fun.data = "mean_cl_boot",geom = "errorbar", width = 0.2 )+
  stat_summary(fun.y=mean, geom="line") + 
  geom_jitter(alpha=0.5) +
  scale_y_continuous(limits = c(0, 5),
                         breaks = seq(0, 5,1),  
                         expand = c(0, 0),
                         name=("dBW [mg / g*day]"))
AW_Bias + facet_grid(~Disease)+
  theme(legend.position = "bottom")

#Summary<-BW.data %>% group_by(Genotype, Nutrients, Disease) %>% count(Date)
#BW_Tall2<-BW.data %>% group_by(Disease, Genotype, Nutrients) %>% add_count(Date)
#write.csv(Summary, "numbers.csv")

Packages used

# Creates bibliography 
#knitr::write_bib(c(.packages()), "packages.bib")

Henry, Lionel, and Hadley Wickham. 2019. Purrr: Functional Programming Tools. https://CRAN.R-project.org/package=purrr.

Müller, Kirill, and Hadley Wickham. 2019. Tibble: Simple Data Frames. https://CRAN.R-project.org/package=tibble.

R Core Team. 2020. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. https://www.R-project.org/.

Wickham, Hadley. 2017a. Reshape2: Flexibly Reshape Data: A Reboot of the Reshape Package. https://CRAN.R-project.org/package=reshape2.

———. 2017b. Tidyverse: Easily Install and Load the ’Tidyverse’. https://CRAN.R-project.org/package=tidyverse.

———. 2019a. Forcats: Tools for Working with Categorical Variables (Factors). https://CRAN.R-project.org/package=forcats.

———. 2019b. Stringr: Simple, Consistent Wrappers for Common String Operations. https://CRAN.R-project.org/package=stringr.

Wickham, Hadley, and Lionel Henry. 2020. Tidyr: Tidy Messy Data. https://CRAN.R-project.org/package=tidyr.

Wickham, Hadley, Winston Chang, Lionel Henry, Thomas Lin Pedersen, Kohske Takahashi, Claus Wilke, Kara Woo, and Hiroaki Yutani. 2019. Ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics. https://CRAN.R-project.org/package=ggplot2.

Wickham, Hadley, Romain François, Lionel Henry, and Kirill Müller. 2019. Dplyr: A Grammar of Data Manipulation. https://CRAN.R-project.org/package=dplyr.

Wickham, Hadley, Jim Hester, and Romain Francois. 2018. Readr: Read Rectangular Text Data. https://CRAN.R-project.org/package=readr.