R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

library(agricolae)
marca <- factor(rep(c("Sello_Rojo","La_Bastilla","Colcafe"), times = 6),
                levels = c("Sello_Rojo","La_Bastilla","Colcafe"))
juez <- factor(rep(1:6, each = 3))
aroma <- c(5,2,5, 4,3,2, 3,1,3, 2,4,1, 2,2,3, 3,1,2)
sabor <- c(5,2,5, 3,2,1, 3,2,5, 3,4,1, 3,2,2, 3,2,2)
datos <- data.frame(juez, marca, aroma, sabor)
datos
##    juez       marca aroma sabor
## 1     1  Sello_Rojo     5     5
## 2     1 La_Bastilla     2     2
## 3     1     Colcafe     5     5
## 4     2  Sello_Rojo     4     3
## 5     2 La_Bastilla     3     2
## 6     2     Colcafe     2     1
## 7     3  Sello_Rojo     3     3
## 8     3 La_Bastilla     1     2
## 9     3     Colcafe     3     5
## 10    4  Sello_Rojo     2     3
## 11    4 La_Bastilla     4     4
## 12    4     Colcafe     1     1
## 13    5  Sello_Rojo     2     3
## 14    5 La_Bastilla     2     2
## 15    5     Colcafe     3     2
## 16    6  Sello_Rojo     3     3
## 17    6 La_Bastilla     1     2
## 18    6     Colcafe     2     2
tapply(datos$aroma, datos$marca, mean)
##  Sello_Rojo La_Bastilla     Colcafe 
##    3.166667    2.166667    2.666667
modelo_aroma <- aov(aroma ~ marca + juez, data = datos)
summary(modelo_aroma)
##             Df Sum Sq Mean Sq F value Pr(>F)
## marca        2      3     1.5   1.000  0.402
## juez         5      8     1.6   1.067  0.433
## Residuals   10     15     1.5
tukey_aroma <- TukeyHSD(modelo_aroma, "marca", conf.level = 0.95)
tukey_aroma
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = aroma ~ marca + juez, data = datos)
## 
## $marca
##                        diff       lwr       upr     p adj
## La_Bastilla-Sello_Rojo -1.0 -2.938388 0.9383884 0.3705447
## Colcafe-Sello_Rojo     -0.5 -2.438388 1.4383884 0.7648908
## Colcafe-La_Bastilla     0.5 -1.438388 2.4383884 0.7648908
plot(tukey_aroma)

HSD.test(modelo_aroma, "marca", group = TRUE, console = TRUE)
## 
## Study: modelo_aroma ~ "marca"
## 
## HSD Test for aroma 
## 
## Mean Square Error:  1.5 
## 
## marca,  means
## 
##                aroma      std r  se Min Max  Q25 Q50  Q75
## Colcafe     2.666667 1.366260 6 0.5   1   5 2.00 2.5 3.00
## La_Bastilla 2.166667 1.169045 6 0.5   1   4 1.25 2.0 2.75
## Sello_Rojo  3.166667 1.169045 6 0.5   2   5 2.25 3.0 3.75
## 
## Alpha: 0.05 ; DF Error: 10 
## Critical Value of Studentized Range: 3.876777 
## 
## Minimun Significant Difference: 1.938388 
## 
## Treatments with the same letter are not significantly different.
## 
##                aroma groups
## Sello_Rojo  3.166667      a
## Colcafe     2.666667      a
## La_Bastilla 2.166667      a
tapply(datos$sabor, datos$marca, mean)
##  Sello_Rojo La_Bastilla     Colcafe 
##    3.333333    2.333333    2.666667
modelo_sabor <- aov(sabor ~ marca + juez, data = datos)
summary(modelo_sabor)
##             Df Sum Sq Mean Sq F value Pr(>F)
## marca        2  3.111   1.556   1.000  0.402
## juez         5  8.444   1.689   1.086  0.424
## Residuals   10 15.556   1.556
tukey_sabor <- TukeyHSD(modelo_sabor, "marca", conf.level = 0.95)
tukey_sabor
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = sabor ~ marca + juez, data = datos)
## 
## $marca
##                              diff       lwr       upr     p adj
## La_Bastilla-Sello_Rojo -1.0000000 -2.973958 0.9739581 0.3826553
## Colcafe-Sello_Rojo     -0.6666667 -2.640625 1.3072914 0.6371795
## Colcafe-La_Bastilla     0.3333333 -1.640625 2.3072914 0.8898461
plot(tukey_sabor)

HSD.test(modelo_sabor, "marca", group = TRUE, console = TRUE)
## 
## Study: modelo_sabor ~ "marca"
## 
## HSD Test for sabor 
## 
## Mean Square Error:  1.555556 
## 
## marca,  means
## 
##                sabor       std r        se Min Max  Q25 Q50  Q75
## Colcafe     2.666667 1.8618987 6 0.5091751   1   5 1.25   2 4.25
## La_Bastilla 2.333333 0.8164966 6 0.5091751   2   4 2.00   2 2.00
## Sello_Rojo  3.333333 0.8164966 6 0.5091751   3   5 3.00   3 3.00
## 
## Alpha: 0.05 ; DF Error: 10 
## Critical Value of Studentized Range: 3.876777 
## 
## Minimun Significant Difference: 1.973958 
## 
## Treatments with the same letter are not significantly different.
## 
##                sabor groups
## Sello_Rojo  3.333333      a
## Colcafe     2.666667      a
## La_Bastilla 2.333333      a
shapiro.test(residuals(modelo_aroma))
## 
##  Shapiro-Wilk normality test
## 
## data:  residuals(modelo_aroma)
## W = 0.94245, p-value = 0.319
bartlett.test(aroma ~ marca, data = datos)
## 
##  Bartlett test of homogeneity of variances
## 
## data:  aroma by marca
## Bartlett's K-squared = 0.1535, df = 2, p-value = 0.9261
shapiro.test(residuals(modelo_sabor))
## 
##  Shapiro-Wilk normality test
## 
## data:  residuals(modelo_sabor)
## W = 0.94293, p-value = 0.3249
bartlett.test(sabor ~ marca, data = datos)
## 
##  Bartlett test of homogeneity of variances
## 
## data:  sabor by marca
## Bartlett's K-squared = 4.4897, df = 2, p-value = 0.1059
par(mfrow = c(1, 2))
boxplot(aroma ~ marca, data = datos, main = "Aroma",
        xlab = "Marca de café", ylab = "Calificación", col = "lightblue")
boxplot(sabor ~ marca, data = datos, main = "Sabor",
        xlab = "Marca de café", ylab = "Calificación", col = "lightpink")

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.