library(readxl)
ANCOVApH <- read_excel("C:/Users/juanc/OneDrive/Escritorio/2021-1/Suelos/Disenio/ANCOVApH.xlsx")
ANCOVApH
## # A tibble: 35 x 5
## Tratamientos pH CIC y x
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 T3 7.6 15.6 1 1
## 2 T4 7.82 18.4 2 1
## 3 T1 6.3 18.8 3 1
## 4 T4 7.9 19.1 4 1
## 5 T0 5.5 21.5 5 1
## 6 T2 7.4 23.7 6 1
## 7 T4 7.89 25.7 7 1
## 8 T4 7.89 15.4 1 2
## 9 T4 7.89 16.7 2 2
## 10 T3 7.6 17.4 3 2
## # ... with 25 more rows
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.0.5
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
df= ANCOVApH
df %>% ggplot(aes(x = x, y=y, colour=pH))+
geom_point(size = 15,shape=15)+
scale_color_continuous(type = 'viridis')

df %>% ggplot(aes(x = x, y=y, colour=CIC))+
geom_point(size = 15,shape=15)+
scale_color_continuous(type = 'viridis')

tapply(df$pH,df$Tratamientos,mean)
## T0 T1 T2 T3 T4
## 5.700000 6.544000 7.380000 7.633636 7.865000
tapply(df$CIC,df$Tratamientos,mean)
## T0 T1 T2 T3 T4
## 24.18714 23.61904 20.97290 21.52820 20.25314
library(lattice)
xyplot(df$pH~df$CIC,pch=16)

xyplot(df$pH~df$CIC|df$Tratamientos,pch=19)

ANCOVA
ANCOVA <- aov(df$pH~df$CIC+df$Tratamientos)
summary(ANCOVA)
## Df Sum Sq Mean Sq F value Pr(>F)
## df$CIC 1 1.375 1.375 50.97 7.4e-08 ***
## df$Tratamientos 4 16.194 4.048 150.07 < 2e-16 ***
## Residuals 29 0.782 0.027
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
shapiro.test(ANCOVA$residuals)
##
## Shapiro-Wilk normality test
##
## data: ANCOVA$residuals
## W = 0.93542, p-value = 0.04066
bartlett.test(ANCOVA$residuals,df$Tratamientos)
##
## Bartlett test of homogeneity of variances
##
## data: ANCOVA$residuals and df$Tratamientos
## Bartlett's K-squared = 30.934, df = 4, p-value = 3.157e-06