#install.packages("tidyverse")
#install.packages("ggpubr")
#install.packages("readxl")

library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.2     v purrr   0.3.4
## v tibble  3.0.4     v dplyr   1.0.2
## v tidyr   1.1.2     v stringr 1.4.0
## v readr   1.4.0     v forcats 0.5.0
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(readxl)
library(agricolae)
library(ggpubr)


#import file excel
padi <- readxl::read_excel("soal 3 split blok.xlsx")

#mengubah setiap faKtor dan ulangan ke dalam bentuk factor
padi <- padi %>% mutate_if(is.character,as.factor) %>% mutate(Ulangan=as.factor(Ulangan))
head(padi,10)
## # A tibble: 10 x 4
##    Pupuk   Genotipe Ulangan Hasil_Padi
##    <fct>   <fct>    <fct>        <dbl>
##  1 Kontrol IR-64    1             20.7
##  2 Kontrol IR-64    2             32.1
##  3 Kontrol IR-64    3             29.5
##  4 Kontrol IR-64    4             37.7
##  5 Kontrol 5-969    1             27.7
##  6 Kontrol 5-969    2             33  
##  7 Kontrol 5-969    3             26.3
##  8 Kontrol 5-969    4             37.7
##  9 PK      IR-64    1             30  
## 10 PK      IR-64    2             30.7
#Anova
anova_padi <- with(padi,strip.plot(BLOCK = Ulangan,
                                   COL = Pupuk,ROW = Genotipe,
                                   Y = Hasil_Padi )
                   )
## 
## ANALYSIS STRIP PLOT:  Hasil_Padi 
## Class level information
## 
## Pupuk    :  Kontrol PK N NP NK NPK 
## Genotipe     :  IR-64 5-969 
## Ulangan  :  1 2 3 4 
## 
## Number of observations:  48 
## 
## model Y: Hasil_Padi ~ Ulangan + Pupuk + Ea + Genotipe + Eb + Genotipe:Pupuk + Ec 
## 
## Analysis of Variance Table
## 
## Response: Hasil_Padi
##                Df  Sum Sq Mean Sq F value    Pr(>F)    
## Ulangan         3  197.11   65.70 18.8263 2.402e-05 ***
## Pupuk           5 1674.80  334.96 18.7668 5.616e-06 ***
## Ea             15  267.73   17.85  5.1142  0.001537 ** 
## Genotipe        1    0.04    0.04  0.0317  0.869973    
## Eb              3    3.33    1.11  0.3180  0.812236    
## Genotipe:Pupuk  5   78.59   15.72  4.5038  0.010471 *  
## Ec             15   52.35    3.49                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## cv(a) = 10.6 %, cv(b) = 2.7 %, cv(c) = 4.7 %, Mean = 39.71458