datos de la pagina kaggle

# Kaggle
library(janitor)
## Warning: package 'janitor' was built under R version 4.0.3
## 
## Attaching package: 'janitor'
## The following objects are masked from 'package:stats':
## 
##     chisq.test, fisher.test
library(readr)
data_grup <- read_csv("datos_kaggel_grupos_definitivo - Hoja 1.csv")
## 
## -- Column specification --------------------------------------------------------------------------------------------------
## cols(
##   .default = col_double(),
##   grupo = col_character(),
##   name = col_character(),
##   emoji = col_character(),
##   `Calories (kcal)` = col_character(),
##   `Vitamin A (IU)` = col_character(),
##   `Magnesium (mg)` = col_character(),
##   `Phosphorus (g)` = col_character(),
##   `Potassium (g)` = col_character(),
##   `Sodium (g)` = col_character()
## )
## i Use `spec()` for the full column specifications.
data_grup %>% 
  clean_names() 
library(tidyverse)
## -- Attaching packages --------------------------------------------------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.2     v dplyr   1.0.2
## v tibble  3.0.3     v stringr 1.4.0
## v tidyr   1.1.2     v forcats 0.5.0
## v purrr   0.3.4
## -- Conflicts ------------------------------------------------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
data_grup1 <- data_grup [, -3]
data_grup2 <- data_grup1 %>% 
   mutate(grupo = as.factor(grupo),
         name = as.factor(name)) %>%  clean_names() %>% 
  mutate(calories_kcal = as.numeric(calories_kcal),
         manganese_mg = as.numeric(manganese_mg),
         phosphorus_g = as.numeric(phosphorus_g),
         potassium_g = as.numeric(potassium_g),
         sodium_g = as.numeric(sodium_g),
         vitamin_a_iu = as.numeric(vitamin_a_iu),
         magnesium_mg = as.numeric(magnesium_mg))
data_grup2

graficamos

data_grup2 %>% 
  select(grupo,calories_kcal:zinc_mg) %>% 
  pivot_longer(cols = -grupo, names_to= "variable", values_to= "valores") %>% 
  ggplot(mapping = aes(x=valores, color = grupo, fill = grupo ))+
  facet_wrap(facets = ~variable, scales = "free", ncol = 4)+
  geom_density(alpha = 0.5)+
  scale_x_log10()
## Warning: Transformation introduced infinite values in continuous x-axis
## Warning: Removed 315 rows containing non-finite values (stat_density).
## Warning: Groups with fewer than two data points have been dropped.

## Warning: Groups with fewer than two data points have been dropped.

## Warning: Groups with fewer than two data points have been dropped.

## Warning: Groups with fewer than two data points have been dropped.

## Warning: Groups with fewer than two data points have been dropped.

## Warning: Groups with fewer than two data points have been dropped.

## Warning: Groups with fewer than two data points have been dropped.
## Warning in max(ids, na.rm = TRUE): ningun argumento finito para max; retornando
## -Inf

## Warning in max(ids, na.rm = TRUE): ningun argumento finito para max; retornando
## -Inf

## Warning in max(ids, na.rm = TRUE): ningun argumento finito para max; retornando
## -Inf

## Warning in max(ids, na.rm = TRUE): ningun argumento finito para max; retornando
## -Inf

## Warning in max(ids, na.rm = TRUE): ningun argumento finito para max; retornando
## -Inf

## Warning in max(ids, na.rm = TRUE): ningun argumento finito para max; retornando
## -Inf

## Warning in max(ids, na.rm = TRUE): ningun argumento finito para max; retornando
## -Inf

data_grup2 %>% 
  select(grupo,calories_kcal:zinc_mg) %>% 
  pivot_longer(cols = -grupo, names_to= "variable", values_to= "valores") %>% 
  ggplot(mapping = aes(sample= valores, color = grupo ))+
  facet_wrap(facets = ~variable, scales = "free", ncol = 4)+
  geom_qq()+
  geom_qq_line()