Estadística descriptiva, gráficos, regresión lineal en r y r-commande
Enviado por Lilián Sarabia • 2 de Enero de 2024 • Tarea • 11.686 Palabras (47 Páginas) • 70 Visitas
- TEMA
Estadística descriptiva, gráficos, regresión lineal en r y r-commande
- RESULTADOS
EJERCICIO 3
Escogemos dos conjuntos de datos incorporados en los paquetes Datasets y MASS de R. Los data frame que usaremos son Orange. (https://stat.ethz.ch/R-manual/R-devel/library/datasets/html/Orange.html) e Iris del que ya hemos hablado anteriormente. Deberemos:
- Buscar un resumen de las variables de cada dataset.
- Generar una tabla de frecuencias absolutas y una de relativas con cualquier variable del dataset.
- Generar una tabla de frecuencias absolutas con cada una de las variables del conjunto de datos Orange. ¿Todas las tablas generadas tienen sentido para vosotros?
Desarrollo:
- Resetear el directorio de trabajo para evitar errores al cargar los archivos.
- Instalar los paquetes Dataset y MASS.
installed.packages("dataset")
## Package LibPath Version Priority Depends Imports LinkingTo Suggests
## Enhances License License_is_FOSS License_restricts_use OS_type Archs
## MD5sum NeedsCompilation Built
installed.packages("MASS")
## Package LibPath Version Priority Depends Imports LinkingTo Suggests
## Enhances License License_is_FOSS License_restricts_use OS_type Archs
## MD5sum NeedsCompilation Built
- Cargar el conjunto de datos de los data frame “Orange” e “Iris”.
data("Orange")
data("iris")
Literal A
- Realizar el resumen de las variables del dataset Orange.
summary(Orange)
## Tree age circumference
## 3:7 Min. : 118.0 Min. : 30.0
## 1:7 1st Qu.: 484.0 1st Qu.: 65.5
## 5:7 Median :1004.0 Median :115.0
## 2:7 Mean : 922.1 Mean :115.9
## 4:7 3rd Qu.:1372.0 3rd Qu.:161.5
## Max. :1582.0 Max. :214.0
- Realizar el resumen de las variables del dataset Iris.
summary(iris)
## Sepal.Length Sepal.Width Petal.Length Petal.Width
## Min. :4.300 Min. :2.000 Min. :1.000 Min. :0.100
## 1st Qu.:5.100 1st Qu.:2.800 1st Qu.:1.600 1st Qu.:0.300
## Median :5.800 Median :3.000 Median :4.350 Median :1.300
## Mean :5.843 Mean :3.057 Mean :3.758 Mean :1.199
## 3rd Qu.:6.400 3rd Qu.:3.300 3rd Qu.:5.100 3rd Qu.:1.800
## Max. :7.900 Max. :4.400 Max. :6.900 Max. :2.500
## Species
## setosa :50
## versicolor:50
## virginica :50
##
Literal B
- Generar una tabla de frecuencias absolutas de la variable “Sepal.Width” del dataset Iris.
table(iris$Sepal.Width)
##
## 2 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4
## 1 3 4 3 8 5 9 14 10 26 11 13 6 12 6 4 3 6 2 1
## 4.1 4.2 4.4
## 1 1 1
- Crear una tabla de frecuencias relativas de la variable “Sepal.Width” del dataset Iris.
prop.table(iris$Sepal.Width)
## [1] 0.007631923 0.006541648 0.006977758 0.006759703 0.007849978 0.008504143
## [7] 0.007413868 0.007413868 0.006323594 0.006759703 0.008068033 0.007413868
## [13] 0.006541648 0.006541648 0.008722198 0.009594418 0.008504143 0.007631923
## [19] 0.008286088 0.008286088 0.007413868 0.008068033 0.007849978 0.007195813
## [25] 0.007413868 0.006541648 0.007413868 0.007631923 0.007413868 0.006977758
## [31] 0.006759703 0.007413868 0.008940253 0.009158308 0.006759703 0.006977758
## [37] 0.007631923 0.007849978 0.006541648 0.007413868 0.007631923 0.005015264
## [43] 0.006977758 0.007631923 0.008286088 0.006541648 0.008286088 0.006977758
## [49] 0.008068033 0.007195813 0.006977758 0.006977758 0.006759703 0.005015264
## [55] 0.006105539 0.006105539 0.007195813 0.005233319 0.006323594 0.005887484
## [61] 0.004361099 0.006541648 0.004797209 0.006323594 0.006323594 0.006759703
## [67] 0.006541648 0.005887484 0.004797209 0.005451374 0.006977758 0.006105539
## [73] 0.005451374 0.006105539 0.006323594 0.006541648 0.006105539 0.006541648
## [79] 0.006323594 0.005669429 0.005233319 0.005233319 0.005887484 0.005887484
## [85] 0.006541648 0.007413868 0.006759703 0.005015264 0.006541648 0.005451374
## [91] 0.005669429 0.006541648 0.005669429 0.005015264 0.005887484 0.006541648
## [97] 0.006323594 0.006323594 0.005451374 0.006105539 0.007195813 0.005887484
## [103] 0.006541648 0.006323594 0.006541648 0.006541648 0.005451374 0.006323594
## [109] 0.005451374 0.007849978 0.006977758 0.005887484 0.006541648 0.005451374
## [115] 0.006105539 0.006977758 0.006541648 0.008286088 0.005669429 0.004797209
## [121] 0.006977758 0.006105539 0.006105539 0.005887484 0.007195813 0.006977758
## [127] 0.006105539 0.006541648 0.006105539 0.006541648 0.006105539 0.008286088
## [133] 0.006105539 0.006105539 0.005669429 0.006541648 0.007413868 0.006759703
## [139] 0.006541648 0.006759703 0.006759703 0.006759703 0.005887484 0.006977758
## [145] 0.007195813 0.006541648 0.005451374 0.006541648 0.007413868 0.006541648
...