Untitled

 avatar
unknown
plain_text
2 years ago
509 B
10
Indexable
# Task 2

#download data
cell_data <- read.csv(file = "IntroSysBio.csv", stringsAsFactors = FALSE)

#fit data to nonlinear regression
x <- rbind(cell_data$Time)
y <- cell_data$CellLine1

N0 <- cell_data$CellLine1[1]
r1 <- 0.09

exp_growth <- function(t, N, r){
  dy <- N * exp(r*t)
  return(dy)
}

exp_growth_fit <- nls(y ~ exp_growth(x, N, r), start = c(N = N0, r = r1))

#plot
plot(x, y, col = "red", xlab = " Time [h]", ylab = "Cells", main = "Cell line 1")
lines(x, predict(exp_growth_fit), col = "black")
Editor is loading...