# load packages
suppressMessages(library(reshape2))
suppressMessages(library(drc))

# read in data
data <- read.csv('/Users/majerus/Desktop/temp.graphing/test.csv')

# clean data 
data <- data[-1,]

# melt data
data.long <- melt(data, 'drug')
colnames(data.long) <- c('dose', 'drug', 'response')

# subset data for c3 plot
C3 <- subset(data.long, data.long$drug=="ELQ.349" | data.long$drug=="ELQ.346")

# fit model 
# data needs to be in long format drm(y~x, grouping variable)
modelC3 <- drm(response~dose, drug, fct=LL.4(names=c("Slope", "Lower", "Upper", "ED50")), data=C3)

# plot curve
plot(modelC3, main = "C3 Dose and Response Plot", xlab = "Dose", ylab = "Response")

# calculate ED value 
ED(modelC3, 50)
## 
## Estimated effective doses
## 
##              Estimate Std. Error
## ELQ.346:50 1.5308e-10          0
## ELQ.349:50 6.6194e-11          0