-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddisPM-BlockDesignExple.R
36 lines (21 loc) · 1 KB
/
AddisPM-BlockDesignExple.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
library(readr)
block_design_example <- read_csv("Work/StatsPackages/R/ILRI-RTraining_2022/block_design_example.csv")
View(block_design_example)
str(block_design_example)
block_design_example$Breed <- as.factor(block_design_example$Breed)
block_design_example$Treatment <- as.factor(block_design_example$Treatment)
block_design_example$Block <- as.factor(block_design_example$Block)
str(block_design_example)
boxplot(DryMatterIntake~Breed,data=block_design_example)
t.test(DryMatterIntake~Breed,data=block_design_example)
mymodel <- lm(DryMatterIntake~Block+Breed*Treatment,data=block_design_example)
summary(mymodel)
anova(mymodel)
plot(mymodel)
str(mymodel)
hist(mymodel$residuals)
library(emmeans)
emmeans(mymodel, pairwise ~ Treatment,data=block_design_example)
block_design_example$logDM <- ln(block_design_example$DryMatterIntake)
block_design_example$logDM <- log(block_design_example$DryMatterIntake)
mymodel <- lm(logDM~Block+Breed*Treatment,data=block_design_example)