#https://github.com/EmilHvitfeldt/r-color-palettes
library(ggplot2)
library(RColorBrewer)
#library(colorRamps)


#getPalette <- colorRampPalette(brewer.pal(12, "Set3"))

gg_color_hue <- function(n) {
  hues = seq(15, 375, length = n + 1)
  hcl(h = hues, l = 65, c = 100)[1:n]
}

# library(scales)
# show_col(hue_pal()(30))

cor = gg_color_hue(9)

#cor <- getPalette(9)
#cor <-brewer.pal(12, "Set3")  

# my.path <- dirname(rstudioapi::getActiveDocumentContext()$path)
# setwd(my.path)

pkg <- c("dplyr",
         "car",
         "agricolae",
         "knitr",
         "TukeyC",
         "dae",
         "showtext",
         "readxl",
         "tidyverse",
         "magrittr")

# instale os pacotes abaixo

# install.packages(pkg)

# carregar pacotes
sapply(pkg,
       library,
       character.only = TRUE,
       logical.return = TRUE)
##     dplyr       car agricolae     knitr    TukeyC       dae  showtext    readxl 
##      TRUE      TRUE      TRUE      TRUE      TRUE      TRUE      TRUE      TRUE 
## tidyverse  magrittr 
##      TRUE      TRUE
showtext_opts(dpi = 300)

options(knitr.table.format = "pandoc")
options(knitr.kable.NA = '')



# leitura de dados

Resultados

ANOVA

CE

model[["ANOVA"]] %>% kable(digits = 3)
Df Sum Sq Mean Sq F value Pr(>F)
rep 3 1643.269 547.756 19.038 0.000
Lote 4 8657.835 2164.459 75.227 0.000
Ea 12 345.269 28.772
Sementes 1 18954.324 18954.324 227.848 0.000
Lote:Sementes 4 630.321 157.580 1.894 0.164
Eb 15 1247.829 83.189
Tempo 6 899.703 149.950 61.167 0.000
Tempo:Lote 24 236.134 9.839 4.013 0.000
Tempo:Sementes 6 295.057 49.176 20.060 0.000
Tempo:Lote:Sementes 24 353.699 14.737 6.012 0.000
Ec 180 441.265 2.451
# Teste de Tukey

Teste de Tukey

par(mfrow = c(1, 3), cex = 0.6)
plot(
  out1,
  xlab = "Lote",
  las = 1,
  variation = "IQR",
  ylab = 'Condutividade Elétrica (µS.cm-1 .g-1)',
  main = "Grupos e Amplitude interquartil"
)
plot(
  out2,
  xlab = "Sementes",
  variation = "IQR",
  ylab = 'Condutividade Elétrica (µS.cm-1 .g-1)',
  main = "Grupos e Amplitude interquartil"
)
plot(
  out3,
  xlab = "Tempo",
  variation = "IQR",
  ylab = 'Condutividade Elétrica (µS.cm-1 .g-1)',
  main = "Grupos e Amplitude interquartil"
)

# Anova com pacote base para comparar com agricolae e fazer os gráficos de interação

Interação

par(mfrow = c(1, 1))


pss %>% with(
  interaction.plot(
    Lote,
    Tempo,
    CE,
    xlab = 'Lote',
    ylab = 'Condutividade Elétrica (µS.cm-1 .g-1)',
    #col = c('red', "green", "blue", "pink", "black", "orange"),
    col = cor,
    lwd = 2
  )
)

pss %>% with(
  interaction.plot(
    Sementes,
    Tempo,
    CE,
    xlab = 'Sementes',
    ylab = 'Condutividade Elétrica (µS.cm-1 .g-1)',
    #col = c('red', "green", "blue", "pink", "black", "orange"),
    col = cor,
    lwd = 2
  )
)

boxplot(
  CE ~ Tempo,
  data = pss,
  col = cor,
  xlab = "Tempo",
  ylab = 'Condutividade Elétrica (µS.cm-1 .g-1)'
)

pss %>% with(
  interaction.plot(
    Lote,
    Sementes,
    CE,
    xlab = 'Lote',
    ylab = 'Condutividade Elétrica (µS.cm-1 .g-1)',
    #col = c("red", "green", 'blue'),
    col = cor,
    lwd = 2
  )
)

boxplot(
  CE ~ Sementes,
  data = pss,
  col = cor,
  xlab = "Sementes",
  ylab = 'Condutividade Elétrica (µS.cm-1 .g-1)'
)

pss %>% with(
  interaction.plot(
    Tempo,
    Sementes,
    CE,
    xlab = 'Tempo',
    ylab = 'Condutividade Elétrica (µS.cm-1 .g-1)',
    #col = c("red", "green", 'blue'),
    col = cor,
    lwd = 2
  )
)

boxplot(
  CE ~ Lote,
  data = pss,
  col = cor,
  xlab = "Lote",
  ylab = 'Condutividade Elétrica (µS.cm-1 .g-1)'
)

pss %>% with(
  interaction.plot(
    Sementes,
    Lote,
    CE,
    xlab = 'Sementes',
    ylab = 'Condutividade Elétrica (µS.cm-1 .g-1)',
    #col = c('red', "green", "blue", "pink", "black", "orange", "cyan"),
    col = cor,
    lwd = 2
  )
)

pss %>% with(
  interaction.plot(
    Tempo,
    Lote,
    CE,
    xlab = 'Tempo',
    ylab = 'Condutividade Elétrica (µS.cm-1 .g-1)',
    col = cor,
    lwd = 2
  )
)

Gráfico de interação tripla

Interação Tripla

a<- interaction.ABC.plot(CE,
                     Tempo,
                     Lote,
                     Sementes,
                     title="",
                     ylab = 'Condutividade Elétrica (µS.cm-1 .g-1)',
                     data = pss) + theme_minimal()

a

# Observa-se efeito significativo de épocas, cultivares e interação.

Testes de comparação de médias

Efeitos principais

Lote

tkc <- AOV %>% TukeyC(which = 'Lote',
                      error = 'rep:Lote')

tkc[["out"]][["Result"]] %>% kable
Means G1 G2 G3 G4
UNA1 35.32 a
UNA2 27.62 b
BUERAREMA 24.40 c
ITAJUIPE 21.60 c d
ITAMARACA 21.11 d

Sementes

tke <- AOV %>% TukeyC(which = 'Sementes',
                      error = 'rep:Lote:Sementes')

tke[["out"]][["Result"]] %>% kable
Means G1 G2
50 33.70 a
25 18.31 b

Tempo

tkd <- AOV %>% TukeyC(which = 'Tempo',
                      error = 'Within')

tkd[["out"]][["Result"]] %>% kable
Means G1 G2 G3
19h 28.05 a
17h 27.56 a b
11h 26.95 a b
15h 26.84 a b
13h 26.04 a b
7h 25.08 b
9h 22.46 c

Lote dentro de Tempo

A/Tempo

tkq <- AOV %>% TukeyC(which = 'Lote:Tempo',
                      error = 'Within',
                      fl1 = 1)

tkq[["out"]][["Result"]] %>% kable
Means G1 G2
UNA1/19h 38.44 a
UNA1/17h 37.64 a b
UNA1/15h 36.76 a b
UNA1/13h 35.98 a b
UNA1/7h 34.46 a b
UNA1/11h 33.36 a b
UNA1/9h 31.44 b

B/Tempo

tks <- AOV %>% TukeyC(which = 'Lote:Tempo',
                      error = 'Within',
                      fl1 = 2)

tks[["out"]][["Result"]] %>% kable
Means G1
UNA2/19h 30.51 a
UNA2/17h 29.86 a
UNA2/15h 29.15 a
UNA2/13h 28.12 a
UNA2/11h 26.55 a
UNA2/7h 26.07 a
UNA2/9h 24.62 a

C/Tempo

tkw <- AOV %>% TukeyC(which = 'Lote:Tempo',
                      error = 'Within',
                      fl1 = 3)

tkw[["out"]][["Result"]] %>% kable
Means G1
BUERAREMA/11h 26.88 a
BUERAREMA/19h 25.73 a
BUERAREMA/17h 25.62 a
BUERAREMA/15h 24.88 a
BUERAREMA/13h 24.02 a
BUERAREMA/7h 23.76 a
BUERAREMA/9h 20.54 a

D/Tempo

tkr <- AOV %>% TukeyC(which = 'Lote:Tempo',
                      error = 'Within',
                      fl1 = 4)

tkr[["out"]][["Result"]] %>% kable
Means G1
ITAJUIPE/11h 24.24 a
ITAJUIPE/19h 23.15 a
ITAJUIPE/17h 22.65 a
ITAJUIPE/15h 21.98 a
ITAJUIPE/13h 21.27 a
ITAJUIPE/7h 20.79 a
ITAJUIPE/9h 17.90 a

E/Tempo

tkt <- AOV %>% TukeyC(which = 'Lote:Tempo',
                      error = 'Within',
                      fl1 = 5)

tkt[["out"]][["Result"]] %>% kable
Means G1
ITAMARACA/11h 23.72 a
ITAMARACA/19h 22.45 a
ITAMARACA/17h 22.04 a
ITAMARACA/15h 21.45 a
ITAMARACA/13h 20.77 a
ITAMARACA/7h 20.34 a
ITAMARACA/9h 17.80 a

Sementes dentro de Tempo

25/Tempo

tkq1 <- AOV %>% TukeyC(which = 'Sementes:Tempo',
                       error = 'Within',
                       fl1 = 1)

tkq1[["out"]][["Result"]] %>% kable
Means G1
25/11h 19.82 a
25/19h 19.35 a
25/17h 19.02 a
25/15h 18.59 a
25/13h 18.05 a
25/7h 17.34 a
25/9h 16.98 a

50/Tempo

tks1 <- AOV %>% TukeyC(which = 'Sementes:Tempo',
                       error = 'Within',
                       fl1 = 2)

tks1[["out"]][["Result"]] %>% kable
Means G1 G2 G3
50/19h 36.76 a
50/17h 36.11 a b
50/15h 35.09 a b
50/11h 34.09 a b
50/13h 34.02 a b
50/7h 32.82 b
50/9h 27.94 c

Lote / Sementes dentro de Tempo

A/Sementes/Tempo

tkq2 <- AOV %>% TukeyC(
  which = 'Lote:Sementes:Tempo',
  error = 'Within',
  fl1 = 1,
  fl2 = 1
)

tkq2[["out"]][["Result"]] %>% kable
Means G1
UNA1/25/19h 27.00 a
UNA1/25/17h 26.62 a
UNA1/25/15h 26.23 a
UNA1/25/13h 25.60 a
UNA1/25/7h 24.32 a
UNA1/25/11h 23.85 a
UNA1/25/9h 22.27 a
tkq3 <- AOV %>% TukeyC(
  which = 'Lote:Sementes:Tempo',
  error = 'Within',
  fl1 = 1,
  fl2 = 2
)

tkq3[["out"]][["Result"]] %>% kable
Means G1 G2
UNA1/50/19h 49.88 a
UNA1/50/17h 48.65 a b
UNA1/50/15h 47.30 a b
UNA1/50/13h 46.35 a b
UNA1/50/7h 44.60 a b
UNA1/50/11h 42.88 a b
UNA1/50/9h 40.60 b

B/Sementes/Tempo

tkq5 <- AOV %>% TukeyC(
  which = 'Lote:Sementes:Tempo',
  error = 'Within',
  fl1 = 2,
  fl2 = 1
)

tkq5[["out"]][["Result"]] %>% kable
Means G1
UNA2/25/9h 23.73 a
UNA2/25/11h 23.23 a
UNA2/25/19h 21.00 a
UNA2/25/17h 20.52 a
UNA2/25/15h 20.07 a
UNA2/25/13h 19.52 a
UNA2/25/7h 19.45 a
tkq6 <- AOV %>% TukeyC(
  which = 'Lote:Sementes:Tempo',
  error = 'Within',
  fl1 = 2,
  fl2 = 2
)

tkq6[["out"]][["Result"]] %>% kable
Means G1 G2 G3
UNA2/50/19h 40.02 a
UNA2/50/17h 39.20 a
UNA2/50/15h 38.23 a b
UNA2/50/13h 36.73 a b
UNA2/50/7h 32.69 a b c
UNA2/50/11h 29.88 b c
UNA2/50/9h 25.52 c

C/Sementes/Tempo

tkq8 <- AOV %>% TukeyC(
  which = 'Lote:Sementes:Tempo',
  error = 'Within',
  fl1 = 3,
  fl2 = 1
)

tkq8[["out"]][["Result"]] %>% kable
Means G1
BUERAREMA/25/11h 19.57 a
BUERAREMA/25/19h 18.18 a
BUERAREMA/25/17h 17.90 a
BUERAREMA/25/15h 17.40 a
BUERAREMA/25/13h 16.75 a
BUERAREMA/25/7h 16.09 a
BUERAREMA/25/9h 14.47 a
tkq9 <- AOV %>% TukeyC(
  which = 'Lote:Sementes:Tempo',
  error = 'Within',
  fl1 = 3,
  fl2 = 2
)

tkq9[["out"]][["Result"]] %>% kable
Means G1
BUERAREMA/50/11h 34.17 a
BUERAREMA/50/17h 33.35 a
BUERAREMA/50/19h 33.27 a
BUERAREMA/50/15h 32.35 a
BUERAREMA/50/7h 31.43 a
BUERAREMA/50/13h 31.30 a
BUERAREMA/50/9h 26.60 a

D/Sementes/Tempo

tko2 <- AOV %>% TukeyC(
  which = 'Lote:Sementes:Tempo',
  error = 'Within',
  fl1 = 4,
  fl2 = 1
)

tko2[["out"]][["Result"]] %>% kable
Means G1
ITAJUIPE/25/11h 15.65 a
ITAJUIPE/25/19h 14.85 a
ITAJUIPE/25/17h 14.62 a
ITAJUIPE/25/15h 14.25 a
ITAJUIPE/25/13h 13.80 a
ITAJUIPE/25/7h 12.66 a
ITAJUIPE/25/9h 11.47 a
tko3 <- AOV %>% TukeyC(
  which = 'Lote:Sementes:Tempo',
  error = 'Within',
  fl1 = 4,
  fl2 = 2
)

tko3[["out"]][["Result"]] %>% kable
Means G1
ITAJUIPE/50/11h 32.83 a
ITAJUIPE/50/19h 31.45 a
ITAJUIPE/50/17h 30.68 a
ITAJUIPE/50/15h 29.70 a
ITAJUIPE/50/7h 28.91 a
ITAJUIPE/50/13h 28.75 a
ITAJUIPE/50/9h 24.32 a

E/Sementes/Tempo

tko5 <- AOV %>% TukeyC(
  which = 'Lote:Sementes:Tempo',
  error = 'Within',
  fl1 = 5,
  fl2 = 1
)

tko5[["out"]][["Result"]] %>% kable
Means G1
ITAMARACA/25/11h 16.77 a
ITAMARACA/25/19h 15.73 a
ITAMARACA/25/17h 15.43 a
ITAMARACA/25/15h 15.00 a
ITAMARACA/25/13h 14.60 a
ITAMARACA/25/7h 14.19 a
ITAMARACA/25/9h 12.97 a
tko6 <- AOV %>% TukeyC(
  which = 'Lote:Sementes:Tempo',
  error = 'Within',
  fl1 = 5,
  fl2 = 2
)

tko6[["out"]][["Result"]] %>% kable
Means G1
ITAMARACA/50/11h 30.67 a
ITAMARACA/50/19h 29.18 a
ITAMARACA/50/17h 28.65 a
ITAMARACA/50/15h 27.90 a
ITAMARACA/50/13h 26.95 a
ITAMARACA/50/7h 26.49 a
ITAMARACA/50/9h 22.62 a
# library(easyanova)
# r2 = ea2(pss, design = 9)

Sementes/Tempo

25/Tempo

tkv1 <- AOV %>% TukeyC(
  which = 'Sementes:Tempo',
  error = 'Within',
  fl1 = 1
)

tkv1[["out"]][["Result"]] %>% kable
Means G1
25/11h 19.82 a
25/19h 19.35 a
25/17h 19.02 a
25/15h 18.59 a
25/13h 18.05 a
25/7h 17.34 a
25/9h 16.98 a

50/Tempo

tkv2 <- AOV %>% TukeyC(
  which = 'Sementes:Tempo',
  error = 'Within',
  fl1 = 2
)

tkv2[["out"]][["Result"]] %>% kable
Means G1 G2 G3
50/19h 36.76 a
50/17h 36.11 a b
50/15h 35.09 a b
50/11h 34.09 a b
50/13h 34.02 a b
50/7h 32.82 b
50/9h 27.94 c

Sementes/Tempo/Lote

25/Tempo/Lote

tkp1 <- AOV %>% TukeyC(
  which = 'Sementes:Tempo:Lote',
  error = 'Within',
  fl1 = 1,
  fl2 = 1
)

tkp1[["out"]][["Result"]] %>% kable
Means G1 G2 G3
25/7h/UNA1 24.32 a
25/7h/UNA2 19.45 a b
25/7h/BUERAREMA 16.09 b c
25/7h/ITAMARACA 14.19 b c
25/7h/ITAJUIPE 12.66 c
tkp2 <- AOV %>% TukeyC(
  which = 'Sementes:Tempo:Lote',
  error = 'Within',
  fl1 = 1,
  fl2 = 2
)

tkp2[["out"]][["Result"]] %>% kable
Means G1 G2 G3
25/9h/UNA2 23.73 a
25/9h/UNA1 22.27 a b
25/9h/BUERAREMA 14.47 b c
25/9h/ITAMARACA 12.97 c
25/9h/ITAJUIPE 11.47 c
tkp3 <- AOV %>% TukeyC(
  which = 'Sementes:Tempo:Lote',
  error = 'Within',
  fl1 = 1,
  fl2 = 3
)

tkp3[["out"]][["Result"]] %>% kable
Means G1
25/11h/UNA1 23.85 a
25/11h/UNA2 23.23 a
25/11h/BUERAREMA 19.57 a
25/11h/ITAMARACA 16.77 a
25/11h/ITAJUIPE 15.65 a
tkp4 <- AOV %>% TukeyC(
  which = 'Sementes:Tempo:Lote',
  error = 'Within',
  fl1 = 1,
  fl2 = 4
)

tkp4[["out"]][["Result"]] %>% kable
Means G1 G2
25/13h/UNA1 25.60 a
25/13h/UNA2 19.52 a b
25/13h/BUERAREMA 16.75 b
25/13h/ITAMARACA 14.60 b
25/13h/ITAJUIPE 13.80 b
tkp5 <- AOV %>% TukeyC(
  which = 'Sementes:Tempo:Lote',
  error = 'Within',
  fl1 = 1,
  fl2 = 5
)

tkp5[["out"]][["Result"]] %>% kable
Means G1 G2
25/15h/UNA1 26.23 a
25/15h/UNA2 20.07 a b
25/15h/BUERAREMA 17.40 b
25/15h/ITAMARACA 15.00 b
25/15h/ITAJUIPE 14.25 b
tkp6 <- AOV %>% TukeyC(
  which = 'Sementes:Tempo:Lote',
  error = 'Within',
  fl1 = 1,
  fl2 = 6
)


tkp6[["out"]][["Result"]] %>% kable
Means G1 G2
25/17h/UNA1 26.62 a
25/17h/UNA2 20.52 a b
25/17h/BUERAREMA 17.90 b
25/17h/ITAMARACA 15.43 b
25/17h/ITAJUIPE 14.62 b
tkp7 <- AOV %>% TukeyC(
  which = 'Sementes:Tempo:Lote',
  error = 'Within',
  fl1 = 1,
  fl2 = 7
)


tkp7[["out"]][["Result"]] %>% kable
Means G1 G2
25/19h/UNA1 27.00 a
25/19h/UNA2 21.00 a b
25/19h/BUERAREMA 18.18 b
25/19h/ITAMARACA 15.73 b
25/19h/ITAJUIPE 14.85 b

50/Tempo/Lote

tkm1 <- AOV %>% TukeyC(
  which = 'Sementes:Tempo:Lote',
  error = 'Within',
  fl1 = 2,
  fl2 = 1
)

tkm1[["out"]][["Result"]] %>% kable
Means G1 G2 G3
50/7h/UNA1 44.60 a
50/7h/UNA2 32.69 b
50/7h/BUERAREMA 31.43 b c
50/7h/ITAJUIPE 28.91 b c
50/7h/ITAMARACA 26.49 c
tkm2 <- AOV %>% TukeyC(
  which = 'Sementes:Tempo:Lote',
  error = 'Within',
  fl1 = 2,
  fl2 = 2
)

tkm2[["out"]][["Result"]] %>% kable
Means G1 G2
50/9h/UNA1 40.60 a
50/9h/BUERAREMA 26.60 b
50/9h/UNA2 25.52 b
50/9h/ITAJUIPE 24.32 b
50/9h/ITAMARACA 22.62 b
tkm3 <- AOV %>% TukeyC(
  which = 'Sementes:Tempo:Lote',
  error = 'Within',
  fl1 = 2,
  fl2 = 3
)

tkm3[["out"]][["Result"]] %>% kable
Means G1 G2
50/11h/UNA1 42.88 a
50/11h/BUERAREMA 34.17 b
50/11h/ITAJUIPE 32.83 b
50/11h/ITAMARACA 30.67 b
50/11h/UNA2 29.88 b
tkm4 <- AOV %>% TukeyC(
  which = 'Sementes:Tempo:Lote',
  error = 'Within',
  fl1 = 2,
  fl2 = 4
)

tkm4[["out"]][["Result"]] %>% kable
Means G1 G2 G3
50/13h/UNA1 46.35 a
50/13h/UNA2 36.73 b
50/13h/BUERAREMA 31.30 b c
50/13h/ITAJUIPE 28.75 b c
50/13h/ITAMARACA 26.95 c
tkm5 <- AOV %>% TukeyC(
  which = 'Sementes:Tempo:Lote',
  error = 'Within',
  fl1 = 2,
  fl2 = 5
)

tkm5[["out"]][["Result"]] %>% kable
Means G1 G2 G3
50/15h/UNA1 47.30 a
50/15h/UNA2 38.23 b
50/15h/BUERAREMA 32.35 b c
50/15h/ITAJUIPE 29.70 c
50/15h/ITAMARACA 27.90 c
tkm6 <- AOV %>% TukeyC(
  which = 'Sementes:Tempo:Lote',
  error = 'Within',
  fl1 = 2,
  fl2 = 6
)

tkm6[["out"]][["Result"]] %>% kable
Means G1 G2 G3
50/17h/UNA1 48.65 a
50/17h/UNA2 39.20 b
50/17h/BUERAREMA 33.35 b c
50/17h/ITAJUIPE 30.68 c
50/17h/ITAMARACA 28.65 c
tkm7 <- AOV %>% TukeyC(
  which = 'Sementes:Tempo:Lote',
  error = 'Within',
  fl1 = 2,
  fl2 = 7
)

tkm7[["out"]][["Result"]] %>% kable
Means G1 G2 G3
50/19h/UNA1 49.88 a
50/19h/UNA2 40.02 b
50/19h/BUERAREMA 33.27 b c
50/19h/ITAJUIPE 31.45 c
50/19h/ITAMARACA 29.18 c
######################################################

Resultados

ANOVA

Germinação

ger <- read_excel("CEjeni.xlsx", sheet = "ger")
ger$lote <- ger$lote %>% factor(.,c("UNA1","UNA2", "BUERAREMA",  "ITAJUIPE" ,  "ITAMARACA")) 
ger <- ger[order(ger$lote),]

av <- aov(ger_per ~ lote, ger)

anova(av) %>% kable
Df Sum Sq Mean Sq F value Pr(>F)
lote 4 3891.2 972.8000 9.306122 0.0005484
Residuals 15 1568.0 104.5333
cv(av) %>% kable
x
cv 17.27
boxplot(ger_per ~ lote,
        ger,
        col = cor,
        xlab = "Lote",
        ylab = 'Germinação (%)')

tk <- TukeyC(av)

tk[["out"]][["Result"]] %>% kable
Means G1 G2
ITAMARACA 75.00 a
ITAJUIPE 73.00 a
BUERAREMA 62.00 a b
UNA1 43.00 b
UNA2 43.00 b
######################################################

Resultados

ANOVA

Emergência

emer <- read_excel("CEjeni.xlsx", sheet = "emer")

emer %<>% gather(lote_r,
                value, -DIAS,
                na.rm = TRUE)


emer %>% separate(lote_r,c("lote","r")) -> emer
names(emer)[1] <- "dias"

emer$lote <- emer$lote %>% factor(.,c("UNA1","UNA2", "BUERAREMA",  "ITAJUIPE" ,  "ITAMARACA")) 
emer <- emer[order(emer$lote),]
#emer$value[emer$value == 0] <- NA



av <- aov(value ~ lote,emer)



anova(av) %>% kable
Df Sum Sq Mean Sq F value Pr(>F)
lote 4 4966.48 1241.62000 18.56908 0
Residuals 795 53157.60 66.86491
cv(av) %>% kable
x
cv 118
boxplot(value ~ lote,
        emer,
        col = cor,
        xlab = "Lote",
        ylab = 'Emergência (%)')

tk <- TukeyC(av)

tk[["out"]][["Result"]] %>% kable
Means G1 G2 G3
BUERAREMA 10.08 a
UNA1 7.93 a b
UNA2 7.23 b
ITAJUIPE 6.98 b
ITAMARACA 2.45 c
emer %>% ggplot(aes(x=dias, y=value, fill=lote)) +
  geom_bar(stat = "identity") +
  xlab('Dias') + ylab('Emergência (%)')+
  theme_bw() +
  scale_fill_manual(values=cor, name="Lote")+
  theme(
    text = element_text(size = 10),
    axis.text.y = element_text(
      angle = 90,
      hjust = 1,
      colour = "black"
    ),
    axis.text.x = element_text(
      angle = 45,
      hjust = 1,
      colour = "black"
    )
  ) + facet_wrap(~lote)

#####################

######################################################

Resultados

ANOVA

T50

t50 <- read_excel("CEjeni.xlsx", sheet = "T50")


t50 %<>% gather(lote_r,
                 value, -DIAS,
                 na.rm = TRUE)


t50 %>% separate(lote_r,c("lote","r")) -> t50
names(t50)[1] <- "dias"

t50$lote <- t50$lote %>% factor(.,c("UNA1","UNA2", "BUERAREMA",  "ITAJUIPE" ,  "ITAMARACA")) 
t50 <- t50[order(t50$lote),]
#emer$value[emer$value == 0] <- NA






av <- aov(value ~ lote,t50)
anova(av) %>% kable
Df Sum Sq Mean Sq F value Pr(>F)
lote 4 5395.58 1348.89500 32.55088 0
Residuals 795 32944.47 41.43958
cv(av) %>% kable
x
cv 65.86
boxplot(value ~ lote,
        t50,
        col = cor,
        xlab = "Lote",
        ylab = 'T50')

tk <- TukeyC(av)

tk[["out"]][["Result"]] %>% kable
Means G1 G2 G3
ITAMARACA 13.24 a
BUERAREMA 11.66 a b
ITAJUIPE 10.38 b
UNA2 6.86 c
UNA1 6.73 c
######################################################

Outros gráficos

names(t50)[4] <- "t50"
names(emer)[4] <- "emer"

df <- merge(t50,emer)

sum_my_rise <- function(x, num_var, ...){
  group_var <- quos(...)
  num_var <- enquo(num_var)
  x %>%
    group_by(!!!group_var) %>%
    summarize(mean = mean(!!num_var), n = n(), 
              min = min(!!num_var),
              max = max(!!num_var),
              sd = sd(!!num_var), se = sd/sqrt(n),
              sum = sum(!!num_var))
}

library(emmeans)


a1 <- aov(t50 ~ lote, data=df)
leastsquare = emmeans(a1,
                      pairwise ~ lote,
                      adjust="tukey")
tkp<-multcomp::cld(leastsquare$emmeans,
                   alpha=0.05,
                   Letters=letters,
                   reversed=T,
                   adjust="tukey") 
ww <- sum_my_rise(df, t50,lote)
ok <- merge(tkp,ww)
pd = position_dodge(1)
p <- ggplot(data = ok, aes(x = lote, y = mean, fill = lote, label=.group)) + 
  theme_minimal() 
p <- p + geom_bar(stat = "identity", position = "dodge") + 
  labs(y = "T50", x = "",
       title = "") +
  geom_text(position = pd, vjust=-0.5, hjust=2) +
  scale_fill_manual(values=cor, name="Lote")+
geom_errorbar(aes(ymin  = mean - se,
                  ymax  = mean + se),
              width = 0.2,
              size  = 0.7,
              position = pd,
              color = "black") +
  theme(
    text = element_text(size = 10),
    axis.text.y = element_text(
      angle = 90,
      hjust = 1,
      colour = "black"),
    axis.text.x = element_text(
      angle = 45,
      hjust = 1,
      colour = "black"
    ))
p

#######################

df$emer <- df$emer/100

a1 <- aov(emer ~ lote, data=df)
leastsquare = emmeans(a1,
                      pairwise ~ lote,
                      adjust="tukey")
tkp<-multcomp::cld(leastsquare$emmeans,
                   alpha=0.05,
                   Letters=letters,
                   reversed=T,
                   adjust="tukey") 
ww <- sum_my_rise(df, emer,lote)
ok <- merge(tkp,ww)
pd = position_dodge(1)
p <- ggplot(data = ok, aes(x = lote, y = mean, fill = lote, label=.group)) + 
  theme_minimal() 
p <- p + geom_bar(stat = "identity", position = "dodge") + 
  labs(y = "Emergência (%)", x = "",
       title = "") +
  scale_y_continuous(labels = scales::percent_format(accuracy = 1))+
  geom_text(position = pd, vjust=-0.5, hjust=2) +
  scale_fill_manual(values=cor, name="Lote")+
  geom_errorbar(aes(ymin  = mean - se,
                    ymax  = mean + se),
                width = 0.2,
                size  = 0.7,
                position = pd,
                color = "black") +
  theme(
    text = element_text(size = 10),
    axis.text.y = element_text(
      angle = 90,
      hjust = 1,
      colour = "black"),
    axis.text.x = element_text(
      angle = 45,
      hjust = 1,
      colour = "black"
    ))
p

#######################################

ger <- read_excel("CEjeni.xlsx", sheet = "ger")
ger$lote <- ger$lote %>% factor(.,c("UNA1","UNA2", "BUERAREMA",  "ITAJUIPE" ,  "ITAMARACA")) 
ger <- ger[order(ger$lote),]

ger$ger_per <- ger$ger_per/100

a1 <- aov(ger_per ~ lote, data=ger)
leastsquare = emmeans(a1,
                      pairwise ~ lote,
                      adjust="tukey")
tkp<-multcomp::cld(leastsquare$emmeans,
                   alpha=0.05,
                   Letters=letters,
                   reversed=T,
                   adjust="tukey") 
ww <- sum_my_rise(ger, ger_per,lote)
ok <- merge(tkp,ww)
pd = position_dodge(1)


p <- ggplot(data = ok, aes(x = lote, y = mean, fill = lote, label=.group)) + 
  theme_minimal() 
p <- p + geom_bar(stat = "identity", position = "dodge") + 
  labs(y = "Germinação (%)", x = "",
       title = "") +
  scale_y_continuous(labels = scales::percent_format(accuracy = 1))+
  geom_text(position = pd, vjust=-0.5, hjust=2) +
  scale_fill_manual(values=cor, name="Lote")+
  geom_errorbar(aes(ymin  = mean - se,
                    ymax  = mean + se),
                width = 0.2,
                size  = 0.7,
                position = pd,
                color = "black") +
  theme(
    text = element_text(size = 10),
    axis.text.y = element_text(
      angle = 90,
      hjust = 1,
      colour = "black"),
    axis.text.x = element_text(
      angle = 45,
      hjust = 1,
      colour = "black"
    ))
p