library(readr)
CardioGoodFitness <- read_csv("C:/Users/juant/Desktop/UCC/PROBABILIDAD Y ESTADISTICA/CardioGoodFitness.csv")
## Rows: 180 Columns: 9
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): Product, Gender, MaritalStatus
## dbl (6): Age, Education, Usage, Fitness, Income, Miles
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
View(CardioGoodFitness)
summary(CardioGoodFitness)
##    Product               Age           Gender            Education    
##  Length:180         Min.   :18.00   Length:180         Min.   :12.00  
##  Class :character   1st Qu.:24.00   Class :character   1st Qu.:14.00  
##  Mode  :character   Median :26.00   Mode  :character   Median :16.00  
##                     Mean   :28.79                      Mean   :15.57  
##                     3rd Qu.:33.00                      3rd Qu.:16.00  
##                     Max.   :50.00                      Max.   :21.00  
##  MaritalStatus          Usage          Fitness          Income      
##  Length:180         Min.   :2.000   Min.   :1.000   Min.   : 29562  
##  Class :character   1st Qu.:3.000   1st Qu.:3.000   1st Qu.: 44059  
##  Mode  :character   Median :3.000   Median :3.000   Median : 50597  
##                     Mean   :3.456   Mean   :3.311   Mean   : 53720  
##                     3rd Qu.:4.000   3rd Qu.:4.000   3rd Qu.: 58668  
##                     Max.   :7.000   Max.   :5.000   Max.   :104581  
##      Miles      
##  Min.   : 21.0  
##  1st Qu.: 66.0  
##  Median : 94.0  
##  Mean   :103.2  
##  3rd Qu.:114.8  
##  Max.   :360.0
mean(CardioGoodFitness$Age)
## [1] 28.78889
median(CardioGoodFitness$Age)
## [1] 26
library(modeest)
mfv(CardioGoodFitness$Age)
## [1] 25
varianza=var(CardioGoodFitness$Age)
varianza
## [1] 48.21217
desviacion=sd(CardioGoodFitness$Age)
desviacion
## [1] 6.943498
library(ggplot2)

ggplot(CardioGoodFitness, aes(x = Age)) +
  geom_histogram(aes(y = ..density..),
                 binwidth = 5, 
                 fill = "lightgreen", 
                 color = "black", 
                 alpha = 0.7) +
  geom_density(alpha = 0.2, fill = "red") +
  labs(title = "Distribución de Edades con Curva de Densidad",
       x = "Edad",
       y = "Densidad") +
  theme_minimal()
## Warning: The dot-dot notation (`..density..`) was deprecated in ggplot2 3.4.0.
## ℹ Please use `after_stat(density)` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.