Se presentan los datos de rendimiento de 2 variedades de arroz: - Porte alto. - Porte baja. Expuestas a 3 niveles de fertilizacion nitrogenada (0, 100 y 200 t/ha). Lleve a cabo el análisis de los datos haciendo análisis exploratorio y análisis de varianza junto con una prueba de medias. También hacer visualización.
library(readr)
arroz <- read_delim("datos/Datos_arroz.csv",
delim = ";", escape_double = FALSE, trim_ws = TRUE)
## Rows: 24 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ";"
## chr (3): Tratamiento, Variedad, Nitrogeno
## dbl (2): Bloque, Rendimiento
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
arroz$Tratamiento <- as.factor(arroz$Tratamiento)
arroz$Variedad <- as.factor(arroz$Variedad)
arroz$Nitrogeno <- as.factor(arroz$Nitrogeno)
arroz$Bloque <- as.factor(arroz$Bloque)
str(arroz)
## spc_tbl_ [24 × 5] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
## $ Tratamiento: Factor w/ 6 levels "T1","T2","T3",..: 1 1 1 1 2 2 2 2 3 3 ...
## $ Variedad : Factor w/ 2 levels "VA","VB": 1 1 1 1 1 1 1 1 1 1 ...
## $ Nitrogeno : Factor w/ 3 levels "N0","N100","N200": 1 1 1 1 2 2 2 2 3 3 ...
## $ Bloque : Factor w/ 4 levels "1","2","3","4": 1 2 3 4 1 2 3 4 1 2 ...
## $ Rendimiento: num [1:24] 7.5 6 7 8.5 8.5 6.8 7.3 8.4 7.6 5.9 ...
## - attr(*, "spec")=
## .. cols(
## .. Tratamiento = col_character(),
## .. Variedad = col_character(),
## .. Nitrogeno = col_character(),
## .. Bloque = col_double(),
## .. Rendimiento = col_double()
## .. )
## - attr(*, "problems")=<externalptr>
Se lleva a cabo un analisis grafico con el pbjetivo de revisar el efecto de las variables sobre la respuesta
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ purrr 1.1.0
## ✔ forcats 1.0.1 ✔ stringr 1.5.2
## ✔ ggplot2 4.0.0 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
arroz %>% ggplot(aes(x = Nitrogeno, y = Rendimiento, fill = Nitrogeno)) +
geom_boxplot() +
geom_jitter(width = 0.2) +
labs(y = "Rendimiento (t/ha)", title = "Efecto del N sobre el Rto", caption = "Author: Luis Fdo Delgado")
arroz %>% ggplot(aes(x = Variedad, y = Rendimiento, fill = Variedad)) +
geom_boxplot() +
geom_jitter(width = 0.2) +
labs(y = "Rendimiento (t/ha)", title = "Efecto del variedad sobre el Rto", caption = "Author: Luis Fdo Delgado")
arroz %>% ggplot(aes(x = Variedad:Nitrogeno, y = Rendimiento, fill = Variedad)) +
geom_boxplot() +
geom_jitter(width = 0.2) +
labs(y = "Rendimiento (t/ha)", title = "Efecto del variedad:Nitrogeno sobre el Rto", caption = "Author: Luis Fdo Delgado")
arroz %>% ggplot(aes(x = Variedad:Nitrogeno, y = Rendimiento, fill = Variedad)) +
facet_wrap(~Bloque) +
geom_col(col = "black") +
labs(y = "Rendimiento (t/ha)", title = "Efecto del variedad:Nitrogeno sobre el Rto", caption = "Author: Luis Fdo Delgado")
## Grafica de interaccion.
Para esta grafica es necesario calcular un estimador para cada tratamiento. El estimador puede ser una media, mediana o moda.
arroz %>% group_by(Variedad, Nitrogeno) %>%
summarise(Rento = mean(Rendimiento)) %>%
ggplot() +
geom_line(aes(x = Nitrogeno, y = Rento, group = Variedad, color = Variedad), size = 0.4) +
labs(y = "Rendimiento (t/ha)", title = "Efecto del Nitrogeno interactuando con la variedad", caption = "Author: Luis Fdo Delgado")
## `summarise()` has grouped output by 'Variedad'. You can override using the
## `.groups` argument.
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
arroz %>% group_by(Variedad, Nitrogeno) %>%
summarise(Rento = mean(Rendimiento)) %>%
ggplot() +
geom_line(aes(x = Variedad, y = Rento, group = Nitrogeno, color = Nitrogeno), size = 0.4) +
labs(y = "Rendimiento (t/ha)", title = "Efecto del variedad interactuando con la Nitrogeno", caption = "Author: Luis Fdo Delgado")
## `summarise()` has grouped output by 'Variedad'. You can override using the
## `.groups` argument.
library(agricolae)
modelo1 <- aov(Rendimiento ~ Bloque + Nitrogeno*Variedad, data = arroz)
summary(modelo1)
## Df Sum Sq Mean Sq F value Pr(>F)
## Bloque 3 17.578 5.859 82.014 1.57e-09 ***
## Nitrogeno 2 3.000 1.500 20.995 4.49e-05 ***
## Variedad 1 0.042 0.042 0.583 0.456904
## Nitrogeno:Variedad 2 2.333 1.167 16.330 0.000172 ***
## Residuals 15 1.072 0.071
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
duncan_compara <- duncan.test(modelo1, c("Variedad","Nitrogeno"), alpha = 0.05)
duncan_compara$groups
## Rendimiento groups
## VB:N200 8.00 a
## VA:N100 7.75 ab
## VB:N100 7.50 bc
## VA:N0 7.25 c
## VA:N200 7.25 c
## VB:N0 6.50 d
bar.group(duncan_compara$groups, ylim = c(0, 10),
xlab = "Tratamientos", ylab = "Rendimiento medio (t/ha)", col = "purple")