library(faux)
##
## ************
## Welcome to faux. For support and examples visit:
## https://scienceverse.github.io/faux/
## - Get and set global package options with: faux_options()
## ************
library(dplyr)
##
## Adjuntando el paquete: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
library(corrplot)
## corrplot 0.95 loaded
library(tidyr)
Duraznos <- faux::rnorm_multi(n=60,vars =2 ,
mu = c(5,5.5),
sd = c(0.4,0-3),
varnames = c("DE","DL"))
##DE: Diámetro Ecuatorial ##DL: Diámetro Longitudinal
Duraznos$loc <- gl(n =2 ,
k =30,
length =60,
labels =c ("Paipa","Pamplona") )
set.seed(123)
resumen_estadistico <- Duraznos %>%
group_by(loc) %>%
summarise(across(c(DE, DL), list(
Media = ~mean(.),
Mediana = ~median(.),
Min = ~min(.),
Max = ~max(.),
Desv_Std = ~sd(.),
CV = ~(sd(.) / mean(.)) * 100
), .names = "{.col}_{.fn}"))
print(as.data.frame(resumen_estadistico))
## loc DE_Media DE_Mediana DE_Min DE_Max DE_Desv_Std DE_CV DL_Media
## 1 Paipa 4.984140 4.900853 4.344319 5.723170 0.3596851 7.216593 5.990017
## 2 Pamplona 4.986076 4.957897 4.101072 5.823629 0.4076297 8.175360 5.101611
## DL_Mediana DL_Min DL_Max DL_Desv_Std DL_CV
## 1 5.830457 1.380862 11.09235 2.834678 47.32337
## 2 4.996132 -3.288114 12.76085 2.944645 57.71990
ggplot(Duraznos, aes(x=loc, y=DE, fill=loc)) +
geom_boxplot() +
labs(title="Boxplot de Diámetro Ecuatorial", x="Localidad", y="DE (cm)") +
theme_minimal()
ggplot(Duraznos, aes(x=DL, fill=loc)) +
geom_histogram(bins=15, alpha=0.6, position="identity") +
labs(title="Histograma de Diámetro Longitudinal", x="DL", y="Frecuencia") +
theme_minimal()
ggplot(Duraznos, aes(x=loc, y=DE, fill=loc)) +
geom_dotplot(binaxis='y', stackdir='center', dotsize=0.8) +
labs(title="Diagrama de Puntos (DE)", x="Localidad", y="DE") +
theme_minimal()
## Bin width defaults to 1/30 of the range of the data. Pick better value with
## `binwidth`.
ggplot(Duraznos, aes(x=DE, y=DL, size=DE, color=loc)) +
geom_point(alpha=0.5) +
scale_size(range = c(1, 10)) +
labs(title="Diagrama de Burbuja (DE vs DL)") +
theme_minimal()
cor_matrix <- cor(Duraznos[, c("DE", "DL")])
corrplot(cor_matrix, method="color", addCoef.col = "black", title="\nCorrelación de Pearson", mar=c(0,0,1,0))
ggplot(Duraznos, aes(x=DE, fill=loc)) +
geom_density(alpha=0.5) +
labs(title="Diagrama de Densidad de DE", x="Diámetro Ecuatorial") +
theme_minimal()
ggplot(Duraznos, aes(x=loc, y=DL, fill=loc)) +
geom_violin(trim=FALSE) +
geom_boxplot(width=0.1, fill="white") +
labs(title="Diagrama de Violín de DL", x="Localidad", y="DL") +
theme_minimal()
ggplot(Duraznos, aes(x = DE, fill = loc)) +
geom_histogram(data = subset(Duraznos, loc == "Paipa"), aes(y = ..count..)) +
geom_histogram(data = subset(Duraznos, loc == "Pamplona"), aes(y = -..count..)) +
coord_flip() +
labs(title="Bihistograma de DE (Paipa arriba vs Pamplona abajo)", y="Frecuencia") +
theme_minimal()