library(readxl)
TRIGO <- read_excel("CARPETA_PARA_RSTUDIO/curso R/Trabajo final curso R/TRIGO.xlsx")
View(TRIGO)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── 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
library(readxl)
library(summarytools) 
## 
## Attaching package: 'summarytools'
## 
## The following object is masked from 'package:tibble':
## 
##     view
library(leaflet)
Bal_datos <- TRIGO %>% 
  filter(Localidad == "BAL")
Bal_datos
## # A tibble: 684 × 5
##      Ano Localidad Tratamiento Genotipo    Rendimiento
##    <dbl> <chr>     <chr>       <chr>             <dbl>
##  1  2007 BAL       ConFung     KleinZorro         3830
##  2  2007 BAL       ConFung     KleinZorro         3030
##  3  2007 BAL       SinFung     KleinTauro         4660
##  4  2007 BAL       SinFung     KleinZorro         3100
##  5  2007 BAL       SinFung     KleinZorro         4170
##  6  2007 BAL       ConFung     KleinZorro         3460
##  7  2007 BAL       SinFung     KleinZorro         3520
##  8  2007 BAL       ConFung     KleinTauro         5200
##  9  2007 BAL       SinFung     KLEINCASTOR        4050
## 10  2007 BAL       ConFung     KLEINCASTOR        3340
## # ℹ 674 more rows

¿Qué variedades se sembraron en su localidad?

tabla_frecuencias <- table(Bal_datos$Genotipo)
print(tabla_frecuencias)
## 
##         ACA801         ACA901         ACA903         ACA905         ACA906 
##              6             33             27              6             27 
##         ACA907        AGPFast           Arex          ATLAX B75ANIVERSARIO 
##             12             27             27             30             24 
##      Baguette9    BIOINTA1001    BIOINTA1002    Biointa1005    Biointa1006 
##             12              6             18             39             39 
##    Biointa1007      BuckPleno    BUCKPUELCHE         Cronox    Floripan100 
##              9              9             18             27              9 
##    KLEINCASTOR     KLEINCHAJA      KleinLeon    KleinNutria      KleinRayo 
##              6              6             24             27             27 
##     KleinTauro     KleinTIGRE     KleinZorro         LE2331         LE2333 
##             45             30             33             33             12 
##         LE2357           ONIX          SY300 
##             12              6             18

En la localidad de Balcarce se sembraron un total de treinta y tres genotipos, las cuales pueden ser visualizadas en la tabla de frecuencia.

Agregar una ubicación ficticia del campo donde se realizó el ensayo teniendo en cuenta la Localidad y Provincia (use el paquete leaflet)

leaflet() %>% ## addProviderTiles(providers$Esri.WorldImagery)%>% 
  addProviderTiles(providers$Esri.WorldImagery) %>% 
  setView(lng = -58.334750, lat = -37.827888, zoom = 15) %>%  # Establece la vista inicial del mapa
  
  addPolygons(lng = c(-58.349706,-58.342132,-58.318528, -58.325974), 
              lat = c(-37.835251,-37.840776,-37.820303,-37.814929), 
              color = "blue") %>% 
  addMarkers(lng = -58.334750, lat = -37.827888)

¿Cuáles fueron los rendimientos alcanzados por las variedades?

Rendimientos medios alcanzados de todos los genotipos.

summary(Bal_datos$Rendimiento)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1029    4468    5229    5197    6064    8263

Rendimientos medios alcanzados por cada genotipo.

library(dplyr)

# Agrupando por variedad y calculando estadísticas
rendimiento_por_variedad <- Bal_datos %>%
  group_by(Genotipo) %>%
  summarise(
    minimo = min(Rendimiento),
    mediana = median(Rendimiento),
    media = mean(Rendimiento),
    maximo = max(Rendimiento))

print(rendimiento_por_variedad)
## # A tibble: 33 × 5
##    Genotipo       minimo mediana media maximo
##    <chr>           <dbl>   <dbl> <dbl>  <dbl>
##  1 ACA801           4250   5070  4938.   5220
##  2 ACA901           2457   4900  5129.   7549
##  3 ACA903           2786   5220  5215.   7203
##  4 ACA905           5696   6072. 6047    6293
##  5 ACA906           2571   6010  5755.   8054
##  6 ACA907           4350   5433  5627.   7230
##  7 AGPFast          3514   5451  5447.   6790
##  8 ATLAX            4090   5600  5603.   7147
##  9 Arex             3214   5082  5331.   7341
## 10 B75ANIVERSARIO   3940   5306. 5229    7462
## # ℹ 23 more rows

¿En líneas generales ¿Se observan diferencias entre los tratamientos “Sin fungicida” y “Con fungicida”

ggplot(Bal_datos, aes(x = Tratamiento, y = Rendimiento, color = Tratamiento)) +
  geom_boxplot(outlier.shape = NA) +
  stat_summary(fun = mean, color = "black", geom = "point", shape= 1, size=3) +
  labs(title =, x= "Tratamiento", y= "Rendimiento (Kg/Ha)") +
  theme_minimal()

En lineas generales mediante la observacion de las lineas de tendencia central (media y mediana) no se observan diferencias significativas que ameriten el uso de fungicidas.

¿Qué variedad recomendaría sembrar?

ggplot(Bal_datos, aes(Rendimiento, Genotipo, colour = Rendimiento)) +
  geom_path() +
  stat_summary(fun.y = mean, geom = "line", aes(group = 1), color = "red", size = 1) + facet_grid(~.)
## Warning: The `fun.y` argument of `stat_summary()` is deprecated as of ggplot2 3.3.0.
## ℹ Please use the `fun` argument instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## 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.

Analizando la grafica se recomienda que el genotipo SY300 es el que manifiesta un mayor rendimiento promedio. Es pertinete mencionar que se selecciono este genotipo debido a que analizando el numero de repeticiones que tenia cada genotipo este es el que presento un valor medio de repeticiones.