Medidas de Tendencia Central
Las medidas de tendencia central y de dispersión son herramientas fundamentales en estadística descriptiva que nos ayudan a resumir y comprender conjuntos de datos.
| Medida de Tendencia Central | Comando en R |
|---|---|
| Media | mean(datos) |
| Media geométrica | exp(mean(log(datos))) |
| Mediana | median(datos) |
| Moda | mlv(datos)$moda |
Las medidas de tendencia central son valores que representan el centro o la concentración de un conjunto de datos. Las tres medidas de tendencia central más comunes son la media, la mediana y la moda.
Media: Es el promedio aritmético de todos los valores en un conjunto de datos. Se calcula sumando todos los valores y dividiendo por el número total de valores. La media puede ser influenciada por valores extremos, por lo que puede no ser la mejor representación si hay datos atípicos.
Mediana: Es el valor que se encuentra en el centro de un conjunto de datos ordenado, es decir, el valor que divide el conjunto en dos mitades iguales. La mediana es menos sensible a los valores atípicos que la media, por lo que puede ser una mejor medida de tendencia central en presencia de datos extremos.
Moda: Es el valor que aparece con mayor frecuencia en un conjunto de datos. Puede haber una moda (unimodal) o más de una moda (bimodal, trimodal, etc.). La moda puede ser útil para identificar valores comunes o patrones en los datos.
Percentiles: Son valores que dividen un conjunto de datos ordenados en 100 partes iguales. El percentil p indica que p% de los datos son iguales o menores que ese valor. Los percentiles son útiles para comprender la distribución de los datos y para identificar valores extremos.
Cuartiles: Son valores que dividen un conjunto de datos ordenados en cuatro partes iguales. Los tres cuartiles (Q1, Q2 y Q3) dividen los datos en cuatro segmentos de 25%. Q2 es la mediana.
##
## 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
## [1] "name" "height" "mass" "hair_color" "skin_color"
## [6] "eye_color" "birth_year" "sex" "gender" "homeworld"
## [11] "species" "films" "vehicles" "starships"
## # A tibble: 6 × 14
## name height mass hair_color skin_color eye_color birth_year sex gender
## <chr> <int> <dbl> <chr> <chr> <chr> <dbl> <chr> <chr>
## 1 Luke Sky… 172 77 blond fair blue 19 male mascu…
## 2 C-3PO 167 75 <NA> gold yellow 112 none mascu…
## 3 R2-D2 96 32 <NA> white, bl… red 33 none mascu…
## 4 Darth Va… 202 136 none white yellow 41.9 male mascu…
## 5 Leia Org… 150 49 brown light brown 19 fema… femin…
## 6 Owen Lars 178 120 brown, gr… light blue 52 male mascu…
## # ℹ 5 more variables: homeworld <chr>, species <chr>, films <list>,
## # vehicles <list>, starships <list>
## [1] 53.74231
## [1] 48.07766
## [1] 50
## [1] 19
## [1] 102
## [1] 19.0 41.9 72.0 82.0
Las medidas de dispersión nos indican cuánto se alejan los datos individuales de la medida de tendencia central. Las dos medidas de dispersión más comunes son el rango y la desviación estándar.
Rango: Es la diferencia entre el valor máximo y el valor mínimo en un conjunto de datos. Proporciona una idea de la amplitud total de los datos. Sin embargo, el rango puede ser sensible a valores extremos y no proporciona información sobre la dispersión de los valores intermedios.
Varianza: Es la medida de dispersión que representa la media de las diferencias al cuadrado entre cada punto de datos y la media del conjunto de datos. La varianza indica qué tan dispersos están los datos alrededor de la media. Sin embargo, al elevar al cuadrado las desviaciones, puede resultar en valores menos intuitivos que la desviación estándar.
Desviación estándar: Es una medida de dispersión que indica cuánto se desvían los valores individuales de la media en un conjunto de datos. Una desviación estándar alta indica que los datos están más dispersos alrededor de la media, mientras que una desviación estándar baja indica que los datos están más concentrados cerca de la media.
Desviación media absoluta (DMA): Es la media de las diferencias absolutas entre cada punto de datos y la media del conjunto de datos. A diferencia de la varianza, la desviación media absoluta no eleva al cuadrado las desviaciones, por lo que puede ser más intuitiva en ciertos contextos.
Coeficiente de variación: Es una medida de dispersión relativa que indica la variabilidad de un conjunto de datos en relación con su media. Se calcula como el cociente entre la desviación estándar y la media, expresado como un porcentaje. El coeficiente de variación es útil para comparar la dispersión de conjuntos de datos con diferentes escalas o unidades.
Estas medidas son esenciales para resumir y comprender conjuntos de datos, permitiendo a los analistas y científicos obtener una visión clara de la distribución y variabilidad de los datos que están estudiando.
## [1] "name" "height" "mass" "hair_color" "skin_color"
## [6] "eye_color" "birth_year" "sex" "gender" "homeworld"
## [11] "species" "films" "vehicles" "starships"
## [1] 52
## [1] 145.1034
# Calcular la desviación estándar
desviacion_estandar <- sd(st.human.height$height)
print(desviacion_estandar)## [1] 12.04589
# Calcular la desviación media absoluta (DMA)
desviacion_media_absoluta <- mean(abs(st.human.height$height - mean(st.human.height$height)))
print(desviacion_media_absoluta)## [1] 9.466667
# Calcular el coeficiente de variación
coeficiente_variacion <- sd(st.human.height$height) / mean(st.human.height$height) * 100
print(coeficiente_variacion)## [1] 6.767354
Elabore un grafico de cajas entre hombres y mujeres humanos vs altura (height)
## [1] "name" "height" "mass" "hair_color" "skin_color"
## [6] "eye_color" "birth_year" "sex" "gender" "homeworld"
## [11] "species" "films" "vehicles" "starships"
## tibble [30 × 14] (S3: tbl_df/tbl/data.frame)
## $ name : chr [1:30] "Luke Skywalker" "Darth Vader" "Leia Organa" "Owen Lars" ...
## $ height : int [1:30] 172 202 150 178 165 183 182 188 180 180 ...
## $ mass : num [1:30] 77 136 49 120 75 84 77 84 NA 80 ...
## $ hair_color: chr [1:30] "blond" "none" "brown" "brown, grey" ...
## $ skin_color: chr [1:30] "fair" "white" "light" "light" ...
## $ eye_color : chr [1:30] "blue" "yellow" "brown" "blue" ...
## $ birth_year: num [1:30] 19 41.9 19 52 47 24 57 41.9 64 29 ...
## $ sex : chr [1:30] "male" "male" "female" "male" ...
## $ gender : chr [1:30] "masculine" "masculine" "feminine" "masculine" ...
## $ homeworld : chr [1:30] "Tatooine" "Tatooine" "Alderaan" "Tatooine" ...
## $ species : chr [1:30] "Human" "Human" "Human" "Human" ...
## $ films :List of 30
## ..$ : chr [1:5] "A New Hope" "The Empire Strikes Back" "Return of the Jedi" "Revenge of the Sith" ...
## ..$ : chr [1:4] "A New Hope" "The Empire Strikes Back" "Return of the Jedi" "Revenge of the Sith"
## ..$ : chr [1:5] "A New Hope" "The Empire Strikes Back" "Return of the Jedi" "Revenge of the Sith" ...
## ..$ : chr [1:3] "A New Hope" "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr [1:3] "A New Hope" "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr "A New Hope"
## ..$ : chr [1:6] "A New Hope" "The Empire Strikes Back" "Return of the Jedi" "The Phantom Menace" ...
## ..$ : chr [1:3] "The Phantom Menace" "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr [1:2] "A New Hope" "Revenge of the Sith"
## ..$ : chr [1:4] "A New Hope" "The Empire Strikes Back" "Return of the Jedi" "The Force Awakens"
## ..$ : chr [1:3] "A New Hope" "The Empire Strikes Back" "Return of the Jedi"
## ..$ : chr [1:5] "The Empire Strikes Back" "Return of the Jedi" "The Phantom Menace" "Attack of the Clones" ...
## ..$ : chr [1:3] "The Empire Strikes Back" "Return of the Jedi" "Attack of the Clones"
## ..$ : chr [1:2] "The Empire Strikes Back" "Return of the Jedi"
## ..$ : chr "The Empire Strikes Back"
## ..$ : chr "Return of the Jedi"
## ..$ : chr "The Phantom Menace"
## ..$ : chr "The Phantom Menace"
## ..$ : chr [1:3] "The Phantom Menace" "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr "The Phantom Menace"
## ..$ : chr "The Phantom Menace"
## ..$ : chr [1:2] "The Phantom Menace" "Attack of the Clones"
## ..$ : chr [1:3] "The Phantom Menace" "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr "Attack of the Clones"
## ..$ : chr "Attack of the Clones"
## ..$ : chr [1:2] "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr [1:2] "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr "Attack of the Clones"
## ..$ : chr "Attack of the Clones"
## ..$ : chr [1:2] "A New Hope" "Revenge of the Sith"
## $ vehicles :List of 30
## ..$ : chr [1:2] "Snowspeeder" "Imperial Speeder Bike"
## ..$ : chr(0)
## ..$ : chr "Imperial Speeder Bike"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "Tribubble bongo"
## ..$ : chr [1:2] "Zephyr-G swoop bike" "XJ-6 airspeeder"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "Snowspeeder"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "Tribubble bongo"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "Flitknot speeder"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## $ starships :List of 30
## ..$ : chr [1:2] "X-wing" "Imperial shuttle"
## ..$ : chr "TIE Advanced x1"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "X-wing"
## ..$ : chr [1:5] "Jedi starfighter" "Trade Federation cruiser" "Naboo star skiff" "Jedi Interceptor" ...
## ..$ : chr [1:3] "Naboo fighter" "Trade Federation cruiser" "Jedi Interceptor"
## ..$ : chr(0)
## ..$ : chr [1:2] "Millennium Falcon" "Imperial shuttle"
## ..$ : chr "X-wing"
## ..$ : chr(0)
## ..$ : chr "Slave 1"
## ..$ : chr "Millennium Falcon"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr [1:3] "Naboo fighter" "H-type Nubian yacht" "Naboo star skiff"
## ..$ : chr "Naboo Royal Starship"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
st.height.human$sex <- as.factor(st.height.human$sex)
st.height.human$height <- as.numeric(st.height.human$height)
plot(st.height.human$height~st.height.human$sex)Elabore un grafico de dispersión para visualizar como afecta la Altura a la biomasa
## # A tibble: 6 × 14
## name height mass hair_color skin_color eye_color birth_year sex gender
## <chr> <dbl> <dbl> <chr> <chr> <chr> <dbl> <fct> <chr>
## 1 Luke Sky… 172 77 blond fair blue 19 male mascu…
## 2 Darth Va… 202 136 none white yellow 41.9 male mascu…
## 3 Leia Org… 150 49 brown light brown 19 fema… femin…
## 4 Owen Lars 178 120 brown, gr… light blue 52 male mascu…
## 5 Beru Whi… 165 75 brown light blue 47 fema… femin…
## 6 Biggs Da… 183 84 black light brown 24 male mascu…
## # ℹ 5 more variables: homeworld <chr>, species <chr>, films <list>,
## # vehicles <list>, starships <list>
plot(st.height.human$mass ~st.height.human$height,
xlab='Altura (cms)', ylab='Peso (kg)',
col='blue', pch = 3)Elabore un grafico de cajas para ver como cambian la media y la varianza entre el peso de cada especie
## tibble [81 × 14] (S3: tbl_df/tbl/data.frame)
## $ name : chr [1:81] "Luke Skywalker" "C-3PO" "R2-D2" "Darth Vader" ...
## $ height : int [1:81] 172 167 96 202 150 178 165 97 183 182 ...
## $ mass : num [1:81] 77 75 32 136 49 120 75 32 84 77 ...
## $ hair_color: chr [1:81] "blond" NA NA "none" ...
## $ skin_color: chr [1:81] "fair" "gold" "white, blue" "white" ...
## $ eye_color : chr [1:81] "blue" "yellow" "red" "yellow" ...
## $ birth_year: num [1:81] 19 112 33 41.9 19 52 47 NA 24 57 ...
## $ sex : chr [1:81] "male" "none" "none" "male" ...
## $ gender : chr [1:81] "masculine" "masculine" "masculine" "masculine" ...
## $ homeworld : chr [1:81] "Tatooine" "Tatooine" "Naboo" "Tatooine" ...
## $ species : chr [1:81] "Human" "Droid" "Droid" "Human" ...
## $ films :List of 81
## ..$ : chr [1:5] "A New Hope" "The Empire Strikes Back" "Return of the Jedi" "Revenge of the Sith" ...
## ..$ : chr [1:6] "A New Hope" "The Empire Strikes Back" "Return of the Jedi" "The Phantom Menace" ...
## ..$ : chr [1:7] "A New Hope" "The Empire Strikes Back" "Return of the Jedi" "The Phantom Menace" ...
## ..$ : chr [1:4] "A New Hope" "The Empire Strikes Back" "Return of the Jedi" "Revenge of the Sith"
## ..$ : chr [1:5] "A New Hope" "The Empire Strikes Back" "Return of the Jedi" "Revenge of the Sith" ...
## ..$ : chr [1:3] "A New Hope" "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr [1:3] "A New Hope" "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr "A New Hope"
## ..$ : chr "A New Hope"
## ..$ : chr [1:6] "A New Hope" "The Empire Strikes Back" "Return of the Jedi" "The Phantom Menace" ...
## ..$ : chr [1:3] "The Phantom Menace" "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr [1:2] "A New Hope" "Revenge of the Sith"
## ..$ : chr [1:5] "A New Hope" "The Empire Strikes Back" "Return of the Jedi" "Revenge of the Sith" ...
## ..$ : chr [1:4] "A New Hope" "The Empire Strikes Back" "Return of the Jedi" "The Force Awakens"
## ..$ : chr "A New Hope"
## ..$ : chr [1:3] "A New Hope" "Return of the Jedi" "The Phantom Menace"
## ..$ : chr [1:3] "A New Hope" "The Empire Strikes Back" "Return of the Jedi"
## ..$ : chr "A New Hope"
## ..$ : chr [1:5] "The Empire Strikes Back" "Return of the Jedi" "The Phantom Menace" "Attack of the Clones" ...
## ..$ : chr [1:5] "The Empire Strikes Back" "Return of the Jedi" "The Phantom Menace" "Attack of the Clones" ...
## ..$ : chr [1:3] "The Empire Strikes Back" "Return of the Jedi" "Attack of the Clones"
## ..$ : chr "The Empire Strikes Back"
## ..$ : chr "The Empire Strikes Back"
## ..$ : chr [1:2] "The Empire Strikes Back" "Return of the Jedi"
## ..$ : chr "The Empire Strikes Back"
## ..$ : chr [1:2] "Return of the Jedi" "The Force Awakens"
## ..$ : chr "Return of the Jedi"
## ..$ : chr "Return of the Jedi"
## ..$ : chr "Return of the Jedi"
## ..$ : chr "The Phantom Menace"
## ..$ : chr [1:3] "The Phantom Menace" "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr "The Phantom Menace"
## ..$ : chr [1:3] "The Phantom Menace" "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr [1:2] "The Phantom Menace" "Attack of the Clones"
## ..$ : chr "The Phantom Menace"
## ..$ : chr "The Phantom Menace"
## ..$ : chr "The Phantom Menace"
## ..$ : chr [1:2] "The Phantom Menace" "Attack of the Clones"
## ..$ : chr "The Phantom Menace"
## ..$ : chr "The Phantom Menace"
## ..$ : chr [1:2] "The Phantom Menace" "Attack of the Clones"
## ..$ : chr "The Phantom Menace"
## ..$ : chr "Return of the Jedi"
## ..$ : chr [1:3] "The Phantom Menace" "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr "The Phantom Menace"
## ..$ : chr "The Phantom Menace"
## ..$ : chr "The Phantom Menace"
## ..$ : chr "The Phantom Menace"
## ..$ : chr [1:3] "The Phantom Menace" "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr [1:3] "The Phantom Menace" "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr [1:3] "The Phantom Menace" "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr [1:2] "The Phantom Menace" "Revenge of the Sith"
## ..$ : chr [1:2] "The Phantom Menace" "Revenge of the Sith"
## ..$ : chr [1:2] "The Phantom Menace" "Revenge of the Sith"
## ..$ : chr "The Phantom Menace"
## ..$ : chr [1:3] "The Phantom Menace" "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr [1:2] "The Phantom Menace" "Attack of the Clones"
## ..$ : chr "Attack of the Clones"
## ..$ : chr "Attack of the Clones"
## ..$ : chr "Attack of the Clones"
## ..$ : chr [1:2] "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr [1:2] "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr "Attack of the Clones"
## ..$ : chr "Attack of the Clones"
## ..$ : chr [1:2] "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr [1:2] "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr "Attack of the Clones"
## ..$ : chr "Attack of the Clones"
## ..$ : chr "Attack of the Clones"
## ..$ : chr "Attack of the Clones"
## ..$ : chr "Attack of the Clones"
## ..$ : chr "Attack of the Clones"
## ..$ : chr [1:2] "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr "Attack of the Clones"
## ..$ : chr "Attack of the Clones"
## ..$ : chr [1:2] "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr "Revenge of the Sith"
## ..$ : chr "Revenge of the Sith"
## ..$ : chr [1:2] "A New Hope" "Revenge of the Sith"
## ..$ : chr [1:2] "Attack of the Clones" "Revenge of the Sith"
## ..$ : chr "Revenge of the Sith"
## $ vehicles :List of 81
## ..$ : chr [1:2] "Snowspeeder" "Imperial Speeder Bike"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "Imperial Speeder Bike"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "Tribubble bongo"
## ..$ : chr [1:2] "Zephyr-G swoop bike" "XJ-6 airspeeder"
## ..$ : chr(0)
## ..$ : chr "AT-ST"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "Snowspeeder"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "Tribubble bongo"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "Sith speeder"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "Flitknot speeder"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "Koro-2 Exodrive airspeeder"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "Tsmeu-6 personal wheel bike"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## $ starships :List of 81
## ..$ : chr [1:2] "X-wing" "Imperial shuttle"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "TIE Advanced x1"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "X-wing"
## ..$ : chr [1:5] "Jedi starfighter" "Trade Federation cruiser" "Naboo star skiff" "Jedi Interceptor" ...
## ..$ : chr [1:3] "Naboo fighter" "Trade Federation cruiser" "Jedi Interceptor"
## ..$ : chr(0)
## ..$ : chr [1:2] "Millennium Falcon" "Imperial shuttle"
## ..$ : chr [1:2] "Millennium Falcon" "Imperial shuttle"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "X-wing"
## ..$ : chr "X-wing"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "Slave 1"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "Millennium Falcon"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "Millennium Falcon"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr [1:3] "Naboo fighter" "H-type Nubian yacht" "Naboo star skiff"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "Naboo Royal Starship"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "Scimitar"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "Jedi starfighter"
## ..$ : chr(0)
## ..$ : chr "Naboo fighter"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr "Belbullab-22 starfighter"
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
## ..$ : chr(0)
st.height$height<-as.numeric(st.height$height)
st.height$species<-as.factor(st.height$species)
plot(st.height$height~st.height$species,
xlab='Especies', ylab='Altura (cms)')st.height.mtc <- st %>%
drop_na(height) %>%
group_by(species) %>%
summarize(media = mean(height), desv_est= sd(height))
st.height.mtc## # A tibble: 38 × 3
## species media desv_est
## <chr> <dbl> <dbl>
## 1 Aleena 79 NA
## 2 Besalisk 198 NA
## 3 Cerean 198 NA
## 4 Chagrian 196 NA
## 5 Clawdite 168 NA
## 6 Droid 131. 49.1
## 7 Dug 112 NA
## 8 Ewok 88 NA
## 9 Geonosian 183 NA
## 10 Gungan 209. 14.2
## # ℹ 28 more rows
st.species.n2 <- st %>%
drop_na(height) %>%
group_by(species) %>%
mutate(freq = n()) %>%
filter(freq >= 2) %>%
select(-freq)
st.species.n2$species<-as.factor(st.species.n2$species)
plot(st.species.n2$height~st.species.n2$species,
xlab='Especie', ylab='Altura (cms)',
col='light blue')library(ggplot2)
ggplot(st.species.n2, aes(x = species, y = height, fill = species)) + #Llamar la bd y las variables
geom_boxplot(color = "black", alpha = 0.7) + #Tipo de gr[afico]
scale_fill_brewer(palette = "Set3") + # Colocar paleta de colores
theme_minimal() + # Seleccionar un tema minimalista
labs(x = "Especies", y = "Altura (cms)", title = "Altura por Especie") +
theme(plot.title = element_text(hjust = 0.5)) # Centrar el tituloCalcular la media y la varianza para todas las especies
st %>%
na.omit(st$height) %>%
group_by(species) %>%
summarise(Media = mean(height), Desv_Est = sd(height)) ## # A tibble: 11 × 3
## species Media Desv_Est
## <chr> <dbl> <dbl>
## 1 Cerean 198 NA
## 2 Ewok 88 NA
## 3 Gungan 196 NA
## 4 Human 179. 11.5
## 5 Kel Dor 188 NA
## 6 Mirialan 168 2.83
## 7 Mon Calamari 180 NA
## 8 Trandoshan 190 NA
## 9 Twi'lek 178 NA
## 10 Wookiee 228 NA
## 11 Zabrak 175 NA
Calcular la media y la varianza para los sexos de los humanos