Análisis descriptivo
tabla_resumen <- function(variable) {
tabla <- data.frame(
min = min(variable, na.rm = TRUE),
Q1 = unname(quantile(variable, 0.25, na.rm = TRUE)),
median = median(variable, na.rm = TRUE),
Q3 = unname(quantile(variable, 0.75, na.rm = TRUE)),
max = max(variable, na.rm = TRUE),
mean = mean(variable, na.rm = TRUE),
sd = sd(variable, na.rm = TRUE),
n = sum(!is.na(variable)),
missing = sum(is.na(variable))
)
knitr::kable(tabla)
}
boxplot_personalizado <- function(variable, titulo, unidad, escala) {
boxplot(variable,
col = "lightblue",
main = titulo,
ylab = unidad,
cex.main = 0.8,
cex.axis = 0.8,
axes = FALSE)
axis(2,
at = escala,
labels = format(escala, big.mark = ".", scientific = FALSE))
box()
}
Superficie Agraria Utilizada
tabla_resumen(datos1$sau)
| 384708 |
501428 |
554264 |
607640 |
893652 |
586348.6 |
151094.4 |
9 |
0 |
boxplot_personalizado(datos1$sau,
"Boxplot SAU",
"Hectáreas",
seq(0, 1000000, by = 100000))
## Warning in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L, :
## 'big.mark' y 'decimal.mark' son ambos '.', lo cual puede ser confuso

Número de explotaciones
tabla_resumen(datos1$explot)
| 4496 |
7225 |
9361 |
11678 |
13820 |
9429.444 |
3095.64 |
9 |
0 |
boxplot_personalizado(datos1$explot,
"Boxplot número de explotaciones",
"Nº de explotaciones",
seq(0, 15000, by = 2000))
## Warning in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L, :
## 'big.mark' y 'decimal.mark' son ambos '.', lo cual puede ser confuso

Unidades Ganaderas Totales
tabla_resumen(datos1$ugt)
| 106790 |
221520 |
249949 |
291574 |
616921 |
299333 |
159007 |
9 |
0 |
boxplot_personalizado(datos1$ugt,
"Boxplot UGT",
"Unidades ganaderas",
seq(0, 700000, by = 100000))
## Warning in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L, :
## 'big.mark' y 'decimal.mark' son ambos '.', lo cual puede ser confuso

Ayudas PAC
tabla_resumen(datos1$pac)
| 7412016 |
11463709 |
13084535 |
14444386 |
27526609 |
14324211 |
5763194 |
9 |
0 |
boxplot_personalizado(datos1$pac,
"Boxplot ayudas PAC",
"Euros",
seq(0, 30000000, by = 5000000))
## Warning in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L, :
## 'big.mark' y 'decimal.mark' son ambos '.', lo cual puede ser confuso

Superficie ecológica
tabla_resumen(datos1$eco_ha)
| 3675 |
4338 |
6062 |
8445 |
20079 |
8399.444 |
5965.185 |
9 |
0 |
boxplot_personalizado(datos1$eco_ha,
"Boxplot superficie ecológica",
"Hectáreas",
seq(0, 25000, by = 5000))
## Warning in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L, :
## 'big.mark' y 'decimal.mark' son ambos '.', lo cual puede ser confuso

Tierras de cultivo
tabla_resumen(datos1$tierras_cultivo)
| 179243 |
288543 |
350736 |
472430 |
585457 |
379888.2 |
138957.6 |
9 |
0 |
boxplot_personalizado(datos1$tierras_cultivo,
"Boxplot tierras de cultivo",
"Hectáreas",
seq(0, 700000, by = 100000))
## Warning in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L, :
## 'big.mark' y 'decimal.mark' son ambos '.', lo cual puede ser confuso

Superficie total
tabla_resumen(datos1$superficie_total)
| 692300 |
805200 |
1030700 |
1235000 |
1557800 |
1046922 |
304349.1 |
9 |
0 |
boxplot_personalizado(datos1$superficie_total,
"Boxplot superficie total",
"Hectáreas",
seq(0, 1600000, by = 200000))
## Warning in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L, :
## 'big.mark' y 'decimal.mark' son ambos '.', lo cual puede ser confuso

Intensidad agraria
tabla_resumen(datos1$int)
| 0.1996457 |
0.2336381 |
0.3765347 |
0.409697 |
0.7018148 |
0.3836962 |
0.1685813 |
9 |
0 |
boxplot_personalizado(datos1$int,
"Boxplot intensidad agraria",
"Índice de intensidad",
seq(0, 1, by = 0.1))
## Warning in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L, :
## 'big.mark' y 'decimal.mark' son ambos '.', lo cual puede ser confuso
