Data Analysis Workshop
In this workshop, you will perform data analysis tasks using R.
You will learn to create interactive visualizations, calculate
statistical measures, and interpret the results.
You will use the dplyr, ggplot2, and plotly packages to complete the
tasks.
The goal is to deepen your understanding of data manipulation,
visualization, and statistical analysis.
# Instalar los paquetes
## install.packages("UsingR")
## install.packages("MASS")
## install.packages("ggplot2")
## install.packages("base")
# Cargar los paquetes
## library(UsingR)
## library(MASS)
## library(ggplot2)
## library(base)
Brightness contiene información del brillo de 963 estrellas
El conjunto de datos Brightness pertenece a UsingR
## Cargar la data Brightness
## He creado un df porque la data Brightness sola me generó error
df_brightness <- data.frame(UsingR::brightness)
## Verifico el data frame creado
head(df_brightness)
## UsingR..brightness
## 1 9.10
## 2 9.27
## 3 6.61
## 4 8.06
## 5 8.55
## 6 12.31
str(df_brightness)
## 'data.frame': 966 obs. of 1 variable:
## $ UsingR..brightness: num 9.1 9.27 6.61 8.06 8.55 ...
summary(df_brightness)
## UsingR..brightness
## Min. : 2.070
## 1st Qu.: 7.702
## Median : 8.500
## Mean : 8.418
## 3rd Qu.: 9.130
## Max. :12.430
Histograma
## Generar un Histograma sencillo
## hist.data.frame(df_brightness)
Gráfico de densidad
## Generar un gráfico de densidad sencillo
plot(density(df_brightness$UsingR..brightness),
main = "Gráfico de Densidad",
xlab = "Brillo estrellas",
ylab = "Densidad",
lwd = 2)

Histograma y gráfico de densidad superpuestos
## Histograma y densidad en uno solo
## ggplot(df_brightness, aes(x = df_brightness$UsingR..brightness)) +
## geom_histogram(aes(y = ..density..), binwidth = 1, fill = "blue", color = "black", alpha = 0.5) +
## geom_density(color = "red", size = 1) +
## labs(title = "Histograma y Gráf. Densidad",
## x = "Brillo estrellas",
## y = "Densidad") +
## theme_minimal()