#Librerias y muestra
set.seed(7877)
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(datos)
library(modeest)
library(descriptr)
library(ggplot2)
diamantes <- sample_n(diamantes, size = 120 , replace = FALSE)
head(diamantes)
## # A tibble: 6 × 10
## precio quilate corte color claridad profundidad tabla x y z
## <int> <dbl> <ord> <ord> <ord> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 680 0.31 Ideal E VS2 62.4 54 4.31 4.35 2.7
## 2 3672 0.7 Ideal G IF 60.2 57 5.78 5.84 3.5
## 3 4317 1.01 Regular F SI2 65.3 59 6.28 6.24 4.09
## 4 16975 1.73 Premium F VS2 61.2 58 7.76 7.69 4.73
## 5 1341 0.53 Ideal I VVS2 61.2 56 5.21 5.28 3.21
## 6 15241 1.91 Muy bueno G SI1 63.1 59 7.9 7.86 4.97
media_quilate <- mean(diamantes$quilate)
mediana_quilates <- median(diamantes$quilate)
moda_quilate <- mlv1(diamantes$quilate)
## Warning: argument 'method' is missing. Data are supposed to be continuous.
## Default method 'shorth' is used
cat("La media, mediana y moda de la variable quilates es:", media_quilate, mediana_quilates, moda_quilate)
## La media, mediana y moda de la variable quilates es: 0.8361667 0.72 0.4508333
rango_profundidad <- max(diamantes$profundidad)-min(diamantes$profundidad)
var_profundidad <- var(diamantes$profundidad)
ds_profundidad <- sqrt(var_profundidad)
cv_profundidad <- (ds_profundidad/mean(diamantes$profundidad))*100
cat("Las medidas de variabilidad para la variable profundidad son:", rango_profundidad, var_profundidad, ds_profundidad, cv_profundidad)
## Las medidas de variabilidad para la variable profundidad son: 10.7 2.504303 1.582499 2.557367
percentiles_tabla <- quantile(diamantes$tabla, probs = c(0.25, 0.30, 0.75, 0.78, 0.9), type = 5);percentiles_tabla
## 25% 30% 75% 78% 90%
## 56 56 59 59 60
asimetria_x <- ds_skewness(diamantes$x)
curtosis_x <- ds_kurtosis(diamantes$x)
cat("Las medidad de forma para variable x son:", asimetria_x, curtosis_x)
## Las medidad de forma para variable x son: 0.3436324 -0.9803705
histograma_y <- hist(diamantes$y, col = "purple", ,main = "Histograma variable Y", xlab = "variable y")
tabla_frec <- table(diamantes$y)
cat("La tabla de frecuencia para la variable Y, quedo de la siguiente forma:", tabla_frec)
## La tabla de frecuencia para la variable Y, quedo de la siguiente forma: 1 1 1 1 1 1 1 1 2 1 4 2 1 1 1 3 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 2 1 1 2 1 1 1 1 1 2 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1
tabla_frec_corte <- table(diamantes$corte)
barras_dimantes <- barplot(tabla_frec_corte, col = "darkolivegreen", main = "Frecuencia de diamantes", xlab = "Calidad de corte", ylab = "Cantidad" )
pie_corte <- pie(tabla_frec_corte, main = "Torta de frecuencia variable corte", col = "pink")