Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
434 B
1
Indexable
Never
#download data
cell_data <- read.csv(file = "IntroSysBio.csv", stringsAsFactors = FALSE)

#fit data to nonlinear regression


x <- cell_data$Time
y <- cell_data$CellLine1

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

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

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

plot(x, y, col = "red")
lines(x, predict(exp_growth_fit), col = "black")