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
datos <- read.csv("datos_negocios_8.csv")
head(datos)
## Ciudad Ingresos Satisfecho
## 1 Ciudad B 159.63 1
## 2 Ciudad B 100.79 1
## 3 Ciudad A 107.22 0
## 4 Ciudad B 154.00 0
## 5 Ciudad B 155.07 1
## 6 Ciudad A 153.81 1
El resumen estadistico muestra que el promedio de los ingresos de las ciudades es de 71.622 mil dolares
summary(datos)
## Ciudad Ingresos Satisfecho
## Length:100 Min. : 71.62 Min. :0.00
## Class :character 1st Qu.: 88.83 1st Qu.:0.00
## Mode :character Median :110.92 Median :1.00
## Mean :114.24 Mean :0.54
## 3rd Qu.:139.97 3rd Qu.:1.00
## Max. :159.63 Max. :1.00
library(ggplot2)
ggplot(datos, aes(x = Ciudad, y = Ingresos, fill = Ciudad)) +
geom_boxplot() +
labs(title = "Distribución de Ingresos por Ciudad",
x = "Ciudad",
y = "Ingresos") +
theme_minimal()
ggplot(datos, aes(x = Ciudad, fill = as.factor(Satisfecho))) +
geom_bar(position = "dodge") +
labs(title = "Número de Clientes Satisfechos por Ciudad",
x = "Ciudad",
y = "Frecuencia",
fill = "Satisfecho") +
scale_fill_manual(values = c("lightblue", "coral"), labels = c("No", "Sí")) +
theme_minimal()
En la Ciudad A hay 55 clientes: 33 satisfechos y 22 no satisfechos, por lo que predomina la satisfacción con un 60%. En la Ciudad B hay 45 clientes: 21 satisfechos y 24 no satisfechos, es decir, la mayoría no está satisfecha. Aunque la Ciudad B tiene mayor ingreso promedio (116,32) que la Ciudad A (112,53), presenta menor satisfacción.
ggplot(datos, aes(x = Ingresos)) +
geom_histogram(binwidth = 5, fill = "skyblue", color = "black", alpha = 0.7) +
geom_density(aes(y = ..density.. * 5), color = "blue", size = 1) +
labs(title = "Distribución de los Ingresos",
x = "Ingresos",
y = "Frecuencia") +
theme_minimal()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once per session.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: The dot-dot notation (`..density..`) was deprecated in ggplot2 3.4.0.
## ℹ Please use `after_stat(density)` instead.
## This warning is displayed once per session.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
La gráfica muestra la distribución de los ingresos de 100 clientes, con valores entre 71,62 y 159,63. El ingreso promedio es de 114,24, y la mediana es 110,92, lo que indica que los ingresos se concentran principalmente en niveles medios. También se observan varios clientes con ingresos altos, especialmente cerca de 150 a 160, donde vuelve a aumentar la frecuencia.