library(readxl)
library(drc)
## Loading required package: MASS
## 
## 'drc' has been loaded.
## Please cite R and 'drc' if used for a publication,
## for references type 'citation()' and 'citation('drc')'.
## 
## Attaching package: 'drc'
## The following objects are masked from 'package:stats':
## 
##     gaussian, getInitial
library(magrittr)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following object is masked from 'package:MASS':
## 
##     select
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(gridExtra)
## 
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
## 
##     combine
library(broom)
library(ggplot2)
datosA <- read_excel("C:/Users/Heymdall/Documents/Paula/Echinochloa/Ensayo 6.1/7ddt 6.1.xlsx", sheet = "DRC", range = "A1:D82")
datos7 <- read_excel("C:/Users/Heymdall/Documents/Paula/Echinochloa/Ensayo 6.1/7ddt 6.1.xlsx", 
    sheet = "DRC", range = "A1:D70")
Datos <-datosA %>% 
  mutate_at(vars(ID, Dosis), as.factor) %>%
  as.data.frame()
head(Datos)
DatosDRC <-Datos %>% 
  as.data.frame()

Altura (cm)

## Altura MA
p1 <- Datos %>% 
  filter(ID == "MA") %>%
  ggplot(aes(x = Dosis, y = `Altura (cm)`)) +
  geom_boxplot() +
  scale_fill_manual(values = "black") + ylim(0, 50) +
  labs(title = "Altura MA",
       x = "Dosis (gr i.a)",
       y = "Altura (cm)")

## Altura UM
p2 <- Datos %>% 
  filter(ID == "UM") %>%
  ggplot(aes(x = Dosis, y = `Altura (cm)`)) + 
  geom_boxplot() +
  scale_fill_manual(values = "black") + ylim(0, 50) +
  labs(title = "Altura UM",
       x = "Dosis (gr i.a)",
       y = "Altura (cm)")

## Altura LP
p3 <- Datos %>% 
  filter(ID == "LP") %>%
  ggplot(aes(x = Dosis, y = `Altura (cm)`)) +
  geom_boxplot() +
  scale_fill_manual(values = "black") + ylim(0, 50) +
  labs(title = "Altura LP",
       x = "Dosis (gr i.a)",
       y = "Altura (cm)")

## Altura VE
p4 <- Datos %>% 
  filter(ID == "VE") %>%
  ggplot(aes(x = Dosis, y = `Altura (cm)`)) +
  geom_boxplot() +
  scale_fill_manual(values = "black") + ylim(0, 50) +
  labs(title = "Altura VE",
       x = "Dosis (gr i.a)",
       y = "Altura (cm)")

## Altura AR
p5 <- Datos %>% 
  filter(ID == "AR") %>%
  ggplot(aes(x = Dosis, y = `Altura (cm)`)) +
  geom_boxplot() +
  scale_fill_manual(values = "black") + ylim(0, 50) +
  labs(title = "Altura AR",
       x = "Dosis (gr i.a)",
       y = "Altura (cm)")

grid.arrange(p1, p2,p3, p4, p5, ncol = 2)

fct = LL.4(names=c(“Hill slope”,“Min”,“Max”,“EC50”)))

modelAlt <- drm(data=datos7, 
           formula = `Altura (cm)`~Dosis, 
           curveid = ID,
           fct = LL.4())
tidy(modelAlt)
## Warning in sqrt(diag(varMat)): Se han producido NaNs
plot(modelAlt, legendPos = c(3000,25))

ED (modelAlt, respLev = 50, interval = "delta")
## Warning in sqrt(dEDval %*% varCov %*% dEDval): Se han producido NaNs

## Warning in sqrt(dEDval %*% varCov %*% dEDval): Se han producido NaNs
## 
## Estimated effective doses
## 
##           Estimate Std. Error      Lower      Upper
## e:AR:50   1444.891   9767.620 -18114.432  21004.213
## e:LP:50   1094.210   1483.518  -1876.484   4064.904
## e:UM:50     70.563        NaN        NaN        NaN
compParm(modelAlt,"e","-")
## Warning in sqrt(transVec %*% varMat[ind, ind] %*% transVec): Se han producido
## NaNs
## Warning in sqrt(transVec %*% varMat[ind, ind] %*% transVec): Se han producido
## NaNs
## 
## Comparison of parameter 'e' 
## 
##       Estimate Std. Error t-value p-value
## UM-LP -1023.65        NaN     NaN     NaN
## UM-AR -1374.33        NaN     NaN     NaN
## LP-AR  -350.68    9879.64 -0.0355  0.9718
modelFit(modelAlt)

% Daño

p1 <- Datos %>% 
  filter(ID == "MA") %>%
  ggplot(aes(x = Dosis, y = `% Daño`)) +
  geom_boxplot() +
  scale_fill_manual(values = "black") + ylim(0, 100) +
  labs(title = "% Daño MA",
       x = "Dosis (gr i.a)",
       y = "% Daño")

## Altura UM
p2 <- Datos %>% 
  filter(ID == "UM") %>%
  ggplot(aes(x = Dosis, y = `% Daño`)) + 
  geom_boxplot() +
  scale_fill_manual(values = "black") + ylim(0, 100) +
  labs(title = "% Daño UM",
       x = "Dosis (gr i.a)",
       y = "% Daño")

## Altura LP
p3 <- Datos %>% 
  filter(ID == "LP") %>%
  ggplot(aes(x = Dosis, y = `% Daño`)) +
  geom_boxplot() +
  scale_fill_manual(values = "black") + ylim(0, 100) +
  labs(title = "% Daño LP",
       x = "Dosis (gr i.a)",
       y = "% Daño")

## Altura VE
p4 <- Datos %>% 
  filter(ID == "VE") %>%
  ggplot(aes(x = Dosis, y = `% Daño`)) +
  geom_boxplot() +
  scale_fill_manual(values = "black") + ylim(0, 100) +
  labs(title = "% Daño VE",
       x = "Dosis (gr i.a)",
       y = "% Daño")

## Altura AR
p5 <- Datos %>% 
  filter(ID == "AR") %>%
  ggplot(aes(x = Dosis, y = `% Daño`)) +
  geom_boxplot() +
  scale_fill_manual(values = "black") + ylim(0, 100) +
  labs(title = "% Daño AR",
       x = "Dosis (gr i.a)",
       y = "% Daño")

grid.arrange(p1, p2,p3, p4, p5, ncol = 2)

names=c(“Hill slope”,“Min”,“Max”,“EC50”)

modelDano <- drm(data=datos7[-(47:70),], 
           formula = `% Daño`~Dosis, 
           curveid = ID,
           fct = LL.4())
## Control measurements detected for level: AR
tidy(modelDano)
plot(modelDano, legendPos = c(100,50))

ED (modelDano, respLev = 50, interval = "delta")
## 
## Estimated effective doses
## 
##         Estimate Std. Error    Lower    Upper
## e:LP:50  2135.11    1771.42 -1450.94  5721.16
## e:UM:50   829.63     596.65  -378.22  2037.48
compParm(modelDano,"e","-")
## 
## Comparison of parameter 'e' 
## 
##       Estimate Std. Error t-value p-value
## UM-LP  -1305.5     1869.2 -0.6984  0.4892
modelFit(modelDano)