Análisis de resultados de muestreo

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.4     ✔ 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(skimr)
library(readxl)
library(GGally)
## Warning: package 'GGally' was built under R version 4.4.3
## Registered S3 method overwritten by 'GGally':
##   method from   
##   +.gg   ggplot2

Cargue y procesamiento de datos

datos = read_excel("Muestreo.xlsx") 

datos
## # A tibble: 12 × 19
##    Muestra Epoca  Oxigeno_disuelto    pH Salinidad Conductividad Temperatura
##    <chr>   <chr>             <dbl> <dbl>     <dbl>         <dbl>       <dbl>
##  1 M1      Seca               7.46  7.99      37.3          56.5        20.7
##  2 M2      Seca               8     7.99      37.3          56.5        20.1
##  3 M3      Seca               8.55  8.17      36.1          54.6        19.8
##  4 M4      Seca               7.72  8.01      36.2          55          20.9
##  5 M5      Seca               9.22  7.68      36.3          55.6        17.9
##  6 M6      Seca               7.4   7.79      36.7          55.7        20.8
##  7 M1      Humeda             9.73  7.61      31.6          48.8        21.9
##  8 M2      Humeda             9.91  7.71      28.3          44          22.6
##  9 M3      Humeda            10.7   7.94      31.6          48.6        23.3
## 10 M4      Humeda             9.98  7.83      32.1          49.2        23.3
## 11 M5      Humeda            10.7   7.43      31            47.6        23.4
## 12 M6      Humeda            10.2   7.36      32.7          49.9        23.4
## # ℹ 12 more variables: Fe <dbl>, NO3 <dbl>, NO2 <dbl>, MO6 <dbl>, Zn <dbl>,
## #   Mn <dbl>, DBO <dbl>, Turbiedad <dbl>, Cl2 <dbl>, Cr6 <dbl>, SO42 <dbl>,
## #   PO4 <dbl>

Resumen estadístico de Seca

datos %>% 
  filter(Epoca == "Seca") %>% 
  skim()
Data summary
Name Piped data
Number of rows 6
Number of columns 19
_______________________
Column type frequency:
character 2
numeric 17
________________________
Group variables None

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
Muestra 0 1 2 2 0 6 0
Epoca 0 1 4 4 0 1 0

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
Oxigeno_disuelto 0 1 8.06 0.71 7.40 7.52 7.86 8.41 9.22 ▇▂▁▂▂
pH 0 1 7.94 0.17 7.68 7.84 7.99 8.01 8.17 ▂▂▁▇▂
Salinidad 0 1 36.65 0.54 36.10 36.23 36.50 37.15 37.30 ▇▁▂▁▅
Conductividad 0 1 55.65 0.77 54.60 55.15 55.65 56.30 56.50 ▃▃▇▁▇
Temperatura 0 1 20.03 1.13 17.90 19.88 20.40 20.78 20.90 ▂▁▁▅▇
Fe 0 1 0.33 0.40 0.04 0.07 0.17 0.42 1.08 ▇▁▂▁▂
NO3 0 1 0.52 0.28 0.20 0.32 0.45 0.73 0.90 ▇▃▃▁▇
NO2 0 1 0.01 0.01 0.00 0.00 0.01 0.02 0.04 ▇▁▁▁▃
MO6 0 1 0.07 0.03 0.01 0.07 0.07 0.08 0.10 ▂▁▁▇▂
Zn 0 1 -0.02 0.28 -0.50 -0.05 0.00 0.10 0.34 ▃▁▇▇▃
Mn 0 1 17.68 2.24 13.50 17.42 18.15 19.02 19.80 ▂▁▁▇▅
DBO 0 1 6.58 5.56 0.00 1.40 8.45 11.30 11.30 ▅▁▂▁▇
Turbiedad 0 1 2.68 1.87 1.10 1.48 1.93 3.36 5.99 ▇▁▂▁▂
Cl2 0 1 22.62 1.39 21.13 21.57 22.30 23.61 24.60 ▇▃▃▃▃
Cr6 0 1 0.04 0.02 0.02 0.03 0.05 0.05 0.07 ▇▁▃▇▃
SO42 0 1 94.00 25.35 43.00 98.50 104.00 105.75 110.00 ▂▁▁▁▇
PO4 0 1 0.60 0.11 0.49 0.51 0.56 0.69 0.74 ▇▇▁▁▇

Resumen estadístico durante la época Humeda

datos %>% 
  filter(Epoca == "Humeda") %>% 
  skim()
Data summary
Name Piped data
Number of rows 6
Number of columns 19
_______________________
Column type frequency:
character 2
numeric 17
________________________
Group variables None

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
Muestra 0 1 2 2 0 6 0
Epoca 0 1 6 6 0 1 0

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
Oxigeno_disuelto 0 1 10.20 0.41 9.73 9.93 10.09 10.56 10.69 ▇▃▃▁▇
pH 0 1 7.65 0.23 7.36 7.47 7.66 7.80 7.94 ▇▁▃▃▇
Salinidad 0 1 31.22 1.54 28.30 31.15 31.60 31.98 32.70 ▂▁▁▇▅
Conductividad 0 1 48.02 2.11 44.00 47.85 48.70 49.10 49.90 ▂▁▁▅▇
Temperatura 0 1 22.98 0.61 21.90 22.78 23.30 23.37 23.40 ▂▁▂▁▇
Fe 0 1 0.19 0.13 0.06 0.10 0.16 0.26 0.40 ▇▇▁▃▃
NO3 0 1 4.47 0.76 3.80 3.95 4.20 4.75 5.80 ▇▂▂▁▂
NO2 0 1 0.02 0.01 0.01 0.01 0.02 0.02 0.02 ▃▁▁▁▇
MO6 6 0 NaN NA NA NA NA NA NA
Zn 0 1 0.18 0.03 0.13 0.16 0.18 0.20 0.22 ▃▃▃▇▃
Mn 0 1 4.13 2.64 0.70 2.70 3.55 6.27 7.40 ▃▇▃▁▇
DBO 6 0 NaN NA NA NA NA NA NA
Turbiedad 0 1 3.19 1.25 1.83 2.16 3.05 4.20 4.79 ▇▃▃▁▇
Cl2 0 1 19.17 1.55 16.66 18.89 19.25 19.50 21.49 ▂▁▇▁▂
Cr6 6 0 NaN NA NA NA NA NA NA
SO42 0 1 93.00 2.37 90.00 91.25 93.00 94.75 96.00 ▇▃▁▃▇
PO4 0 1 1.07 0.86 0.30 0.45 0.78 1.48 2.53 ▇▂▁▂▂

Correlación

datos %>%
  drop_na() %>%
  select_if(is.numeric) %>%
  cor() %>%
  round(2)
##                  Oxigeno_disuelto    pH Salinidad Conductividad Temperatura
## Oxigeno_disuelto             1.00 -0.24     -0.51         -0.35       -0.95
## pH                          -0.24  1.00     -0.02         -0.29        0.49
## Salinidad                   -0.51 -0.02      1.00          0.95        0.33
## Conductividad               -0.35 -0.29      0.95          1.00        0.10
## Temperatura                 -0.95  0.49      0.33          0.10        1.00
## Fe                           0.23  0.71     -0.17         -0.38       -0.01
## NO3                          0.22 -0.26      0.24          0.40       -0.36
## NO2                          0.18 -0.87     -0.24         -0.05       -0.36
## MO6                          0.31  0.30      0.16          0.19       -0.28
## Zn                           0.53  0.24      0.15          0.19       -0.45
## Mn                          -0.17 -0.69      0.11          0.32        0.00
## DBO                         -0.43 -0.40      0.88          0.91        0.16
## Turbiedad                    0.52 -0.71      0.11          0.38       -0.74
## Cl2                         -0.09 -0.08      0.84          0.89       -0.07
## Cr6                         -0.01  0.42     -0.08         -0.12        0.07
## SO42                         0.29 -0.06     -0.49         -0.48       -0.16
## PO4                         -0.61 -0.34      0.67          0.65        0.36
##                     Fe   NO3   NO2   MO6    Zn    Mn   DBO Turbiedad   Cl2
## Oxigeno_disuelto  0.23  0.22  0.18  0.31  0.53 -0.17 -0.43      0.52 -0.09
## pH                0.71 -0.26 -0.87  0.30  0.24 -0.69 -0.40     -0.71 -0.08
## Salinidad        -0.17  0.24 -0.24  0.16  0.15  0.11  0.88      0.11  0.84
## Conductividad    -0.38  0.40 -0.05  0.19  0.19  0.32  0.91      0.38  0.89
## Temperatura      -0.01 -0.36 -0.36 -0.28 -0.45  0.00  0.16     -0.74 -0.07
## Fe                1.00 -0.49 -0.45  0.02  0.23 -0.94 -0.31     -0.51 -0.23
## NO3              -0.49  1.00 -0.15  0.79  0.33  0.28  0.13      0.80  0.51
## NO2              -0.45 -0.15  1.00 -0.65 -0.55  0.44  0.24      0.38 -0.35
## MO6               0.02  0.79 -0.65  1.00  0.70 -0.13 -0.18      0.43  0.51
## Zn                0.23  0.33 -0.55  0.70  1.00 -0.10 -0.14      0.23  0.61
## Mn               -0.94  0.28  0.44 -0.13 -0.10  1.00  0.24      0.36  0.23
## DBO              -0.31  0.13  0.24 -0.18 -0.14  0.24  1.00      0.27  0.64
## Turbiedad        -0.51  0.80  0.38  0.43  0.23  0.36  0.27      1.00  0.39
## Cl2              -0.23  0.51 -0.35  0.51  0.61  0.23  0.64      0.39  1.00
## Cr6               0.00  0.66 -0.56  0.77  0.12 -0.24 -0.35      0.18  0.02
## SO42              0.24 -0.74  0.28 -0.57  0.09  0.08 -0.36     -0.41 -0.39
## PO4              -0.34  0.11  0.33 -0.30 -0.58  0.14  0.85      0.16  0.25
##                    Cr6  SO42   PO4
## Oxigeno_disuelto -0.01  0.29 -0.61
## pH                0.42 -0.06 -0.34
## Salinidad        -0.08 -0.49  0.67
## Conductividad    -0.12 -0.48  0.65
## Temperatura       0.07 -0.16  0.36
## Fe                0.00  0.24 -0.34
## NO3               0.66 -0.74  0.11
## NO2              -0.56  0.28  0.33
## MO6               0.77 -0.57 -0.30
## Zn                0.12  0.09 -0.58
## Mn               -0.24  0.08  0.14
## DBO              -0.35 -0.36  0.85
## Turbiedad         0.18 -0.41  0.16
## Cl2               0.02 -0.39  0.25
## Cr6               1.00 -0.74 -0.10
## SO42             -0.74  1.00 -0.55
## PO4              -0.10 -0.55  1.00
datos %>%
  select(Fe, Mn, DBO, Cl2, pH, Salinidad, Temperatura, Conductividad) %>% 
  drop_na() %>%
  ggpairs(
    upper = list(continuous = wrap("cor", size = 3)),
    lower = list(continuous = wrap("smooth", alpha = 0.3)),
    diag = list(continuous = wrap("densityDiag"))
  ) 

Gráfica para análisis bivariado general

datos %>%
  pivot_longer(
    cols = -c(Muestra, Epoca),
    names_to = "Variable",
    values_to = "Valor"
  )%>%
  ggplot(aes(x = Epoca, y = Valor, fill = Epoca)) +
  geom_boxplot() +
  facet_wrap(~ Variable, scales = "free_y")
## Warning: Removed 18 rows containing non-finite outside the scale range
## (`stat_boxplot()`).

Gráfico individual

datos  %>% 
  ggplot(aes(y = Epoca, x = Cl2, fill = Epoca))+
  geom_boxplot()+
  scale_fill_brewer(palette = "Pastel2")

datos  %>% 
  ggplot(aes(y = Epoca, x = Conductividad, fill = Epoca))+
  geom_boxplot()+
  scale_fill_brewer(palette = "Pastel2")

datos  %>% 
  ggplot(aes(y = Epoca, x = Fe, fill = Epoca))+
  geom_boxplot()+
  scale_fill_brewer(palette = "Pastel2")

datos  %>% 
  ggplot(aes(y = Epoca, x = Mn, fill = Epoca))+
  geom_boxplot()+
  scale_fill_brewer(palette = "Pastel2")

datos  %>% 
  ggplot(aes(y = Epoca, x = NO2, fill = Epoca))+
  geom_boxplot()+
  scale_fill_brewer(palette = "Pastel2")

datos  %>% 
  ggplot(aes(y = Epoca, x =NO3, fill = Epoca))+
  geom_boxplot()+
  scale_fill_brewer(palette = "Pastel2")

datos  %>% 
  ggplot(aes(y = Epoca, x =  Oxigeno_disuelto, fill = Epoca))+
  geom_boxplot()+
  scale_fill_brewer(palette = "Pastel2")

datos  %>% 
  ggplot(aes(y = Epoca, x = pH,  fill = Epoca))+
  geom_boxplot()+
  scale_fill_brewer(palette = "Pastel2")

datos  %>% 
  ggplot(aes(y = Epoca, x = PO4, fill = Epoca))+
  geom_boxplot()+
  scale_fill_brewer(palette = "Pastel2")

datos  %>% 
  ggplot(aes(y = Epoca, x = Salinidad, fill = Epoca))+
  geom_boxplot()+
  scale_fill_brewer(palette = "Pastel2")

datos  %>% 
  ggplot(aes(y = Epoca, x = SO42, fill = Epoca))+
  geom_boxplot()+
  scale_fill_brewer(palette = "Pastel2")

datos  %>% 
  ggplot(aes(y = Epoca, x = Temperatura,  fill = Epoca))+
  geom_boxplot()+
  scale_fill_brewer(palette = "Pastel2")

datos  %>% 
  ggplot(aes(y = Epoca, x = Turbiedad, fill = Epoca))+
  geom_boxplot()+
  scale_fill_brewer(palette = "Pastel2")

datos  %>% 
  ggplot(aes(y = Epoca, x = Zn, fill = Epoca))+
  geom_boxplot()+
  scale_fill_brewer(palette = "Pastel2")