# Data in two numeric vectors
parcela1_AGB <- c(38.9, 61.2, 73.3, 21.8, 63.4, 64.6, 48.4, 48.8, 48.5)
parcela2_AGB <- c(67.8, 60, 63.4, 76, 89.4, 73.3, 67.3, 61.3, 62.4)
# Create a data frame
my_data <- data.frame(
parcela = rep(c("uno", "dos"), each = 9),
AGB = c(parcela1_AGB, parcela2_AGB)
)
#Presente un resumen estadistico de los datos. Use el paquete dplyr
library(dplyr)
##
## 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
group_by(my_data, parcela) %>%
summarise(
count = n(),
mean = mean(AGB, na.rm = TRUE),
sd = sd(AGB, na.rm = TRUE)
)
## # A tibble: 2 x 4
## parcela count mean sd
## <fct> <int> <dbl> <dbl>
## 1 dos 9 69.0 9.38
## 2 uno 9 52.1 15.6
# Visualice los datos usando box plots
library("ggpubr")
## Loading required package: ggplot2
## Loading required package: magrittr
ggboxplot(my_data, x = "parcela", y = "AGB",
color = "parcela", palette = c("#00AFBB", "#E7B800"),
ylab = "AGB", xlab = "parcela")

# Realice la prueba de t
res <- t.test(AGB ~ parcela, data = my_data, var.equal = TRUE)
res
##
## Two Sample t-test
##
## data: AGB by parcela
## t = 2.7842, df = 16, p-value = 0.01327
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 4.029759 29.748019
## sample estimates:
## mean in group dos mean in group uno
## 68.98889 52.10000
# Compruebe normalidad
# Shapiro-Wilk normality test for Men's weights
with(my_data, shapiro.test(AGB[parcela == "uno"]))# p = 0.1
##
## Shapiro-Wilk normality test
##
## data: AGB[parcela == "uno"]
## W = 0.94266, p-value = 0.6101
# Shapiro-Wilk normality test for Women's weights
with(my_data, shapiro.test(AGB[parcela == "dos"])) # p = 0.6
##
## Shapiro-Wilk normality test
##
## data: AGB[parcela == "dos"]
## W = 0.86425, p-value = 0.1066
# Homegeneidad de varianzas con F-test
res.ftest <- var.test(AGB ~ parcela, data = my_data)
res.ftest
##
## F test to compare two variances
##
## data: AGB by parcela
## F = 0.36134, num df = 8, denom df = 8, p-value = 0.1714
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
## 0.08150656 1.60191315
## sample estimates:
## ratio of variances
## 0.3613398