# A tibble: 3 × 12
identif tipo edad sexo `direccion 2` `profesion 2` diag ingreso gasto
<dbl> <chr> <dbl> <chr> <chr> <chr> <chr> <dbl> <dbl>
1 3 I 33 Mujer CARAPUNGO-CALDERON QUEHACERES D… FARI… 824 585
2 6 I 11 Mujer COTOCOLLAO ESTUDIANTE DERM… 919 660
3 7 F 37 Mujer NOROCCIDENTE URBA… QUEHACERES D… FARI… 973 633
# … with 3 more variables: altura <dbl>, nse <chr>, educa <chr>
# Gráfico de barras segun sexolibrary(ggplot2)gg.sexo.barras <-ggplot(df.base, aes(sexo)) +geom_bar()gg.sexo.barras
2) Gráfico de puntos
Se genera un gráfico de puntos entre las variables ingreso y gasto, se utiliza la variable cualitativa “nse” para su clasificacion.
library(ggplot2)library(dplyr)
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
gg.puntos <-ggplot(df.base, aes(ingreso, gasto, color = nse))+geom_point()+labs(x ="Ingreso", # Título del eje Xy ="Gasto", # Título del eje Ytitle =" Relacion entre Ingreso y Gasto por NSE"# Título principal ) +theme_minimal()gg.puntos
3) Diagrama de caja o boxplot
Se utiliza la variable cuantitativa “edad” en función de una variable cualitativa “nse”
Relacion entre las variables cuantitativas edad e ingreso, mediante la variable cualitativa sexo (con linea de ajuste).
gg.linea.ajuste <-ggplot(df.base, aes(edad, ingreso, color = sexo))+geom_point()+geom_smooth(method="lm")+labs(x ="Ingreso", # Título del eje Xy ="Gasto", # Título del eje Ytitle =" Relacion entre edad e ingreso por sexo (con linea de ajuste)"# Título principal ) +theme_minimal()gg.linea.ajuste