R/strain_rsqrd.r

Defines functions strain_rsqrd

Documented in strain_rsqrd

# (C) Copyright 2017 Sur Herrera Paredes
# 
# This file is part of wheelP.
# 
# wheelP is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# wheelP is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with wheelP.  If not, see <http://www.gnu.org/licenses/>.

#' Calculate R-squared
#' 
#' @export
strain_rsqrd <- function(Dat){
  RES <- NULL
  for(strain in unique(Dat$Strain)){
    #strain <- unique(Dat$Strain)[2]
    
    Dat.strain <- subset(Dat, Strain == strain)
    Dat.strain <- aggregate(OD600 ~ rep + condition, FUN = sum, data = Dat.strain)
    
    f1 <- OD600 ~ condition
    m1 <- lm(OD600 ~ condition,data = Dat.strain)
    m1.sum <- summary(m1)
    r <- m1.sum$r.squared
    
    Res <- data.frame(Strain = strain, r.squared = r)
    
    RES <- rbind(RES,Res)
  }
  
  return(RES)
}
surh/wheelP documentation built on May 7, 2019, 10:11 a.m.