Objetivo Cargar en el entorno de trabajo de R las librerías necesarias para realizar manipulación de datos, análisis descriptivo y gráficos.
Código en R (Chunk): Descarga de paquetes estadísticos Se instalaron los paquetes de R necesarios.
library(lsm) # Para descargar una base de datos
library(dplyr)
##
## Adjuntando el paquete: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(moments) # Para hallar las medidas de forma
library(e1071)
##
## Adjuntando el paquete: 'e1071'
## The following objects are masked from 'package:moments':
##
## kurtosis, moment, skewness
library(ggplot2)
##
## Adjuntando el paquete: 'ggplot2'
## The following object is masked from 'package:e1071':
##
## element
Salida obtenida: La consola ejecuta los comandos de carga de paquetes (pueden aparecer algunos mensajes informativos sobre versiones o funciones sobreescritas de los paquetes).
Interpretación: Se habilitaron correctamente las 5 librerías requeridas en la memoria de R, dejando disponibles el 100% de las funciones estadísticas y de visualización que se utilizarán en el desarrollo de la práctica
Es una base de datos en forma de tabla (filas = observaciones, columnas = variables). Permite almacenar bases de datos estructuradas antes de aplicar cualquier método inferencial.
datosCompleto <- lsm::survey
Salida obtenida: Se crea el objeto datosCompleto en la sección del entorno (Environment) de RStudio.
Interpretación:Se cargó exitosamente en la memoria activa del programa el conjunto de datos completo, el cual cuenta con un total de 800 observaciones y 66 variables para iniciar el análisis exploratorio.
Explorar la composición general del dataframe para conocer su tipo de objeto, dimensión (número de filas y columnas) y los tipos de variables almacenados.
str(datosCompleto) #A) Estructura de los datos
## tibble [800 × 66] (S3: tbl_df/tbl/data.frame)
## $ Observation : num [1:800] 1 2 3 4 5 6 7 8 9 10 ...
## $ ID : chr [1:800] "SB11201910010435" "SB11201910004475" "SB11201910011427" "SB11201910041975" ...
## $ Gender : chr [1:800] "Female" "Male" "Male" "Male" ...
## $ Like : chr [1:800] "TV" "Network" "Network" "TV" ...
## $ Age : num [1:800] 21.4 21.1 20.9 18.4 16.6 ...
## $ Smoke : chr [1:800] "No" "Yes" "Yes" "Yes" ...
## $ Height : num [1:800] 1.58 1.6 1.5 1.53 1.78 1.65 1.73 1.53 1.64 1.52 ...
## $ Weight : num [1:800] 75 80 64 49 82 80 90 55 50 78 ...
## $ BMI : num [1:800] 30 31.2 28.4 20.9 25.9 ...
## $ School : chr [1:800] "Private" "Public" "Private" "Public" ...
## $ SES : chr [1:800] "Medium" "High" "High" "Low" ...
## $ Enrollment : chr [1:800] "Credit" "Scholarship" "Scholarship" "Credit" ...
## $ Score : num [1:800] 81 78 77 70 68 65 54 50 36 35 ...
## $ MotherHeight: chr [1:800] "Short_M" "Normal_M" "Normal_M" "Tall_M" ...
## $ MotherAge : num [1:800] 41 45 45 45 46 46 47 48 48 48 ...
## $ MotherCHD : num [1:800] 0 0 0 0 1 0 0 0 0 1 ...
## $ FatherHeight: chr [1:800] "Normal_F" "Short_F" "Tall_F" "Short_F" ...
## $ FatherAge : num [1:800] 40 43 44 45 45 46 46 48 48 49 ...
## $ FatherCHD : num [1:800] 1 1 1 2 1 1 1 1 1 1 ...
## $ Status : chr [1:800] "Distinguished" "Distinguished" "Distinguished" "Regular" ...
## $ SemAcum : num [1:800] 4.25 2.8 4.15 3.2 3.45 2.75 2.7 4.35 4.3 2.8 ...
## $ Exam1 : num [1:800] 1.5 2.3 3.4 2.5 3.1 3.8 5 4 2.5 2.4 ...
## $ Exam2 : num [1:800] 5 4.9 3.6 4.2 3.5 4.4 3 2.3 3.3 2.6 ...
## $ Exam3 : num [1:800] 5 3.7 2 5 5 4.2 3.5 4.6 3.8 4.3 ...
## $ Exam4 : num [1:800] 4.5 3.3 1.9 2.5 3 5 3.6 4.3 1.9 5 ...
## $ ExamAcum : num [1:800] 16 14.2 10.9 14.2 14.6 17.4 15.1 15.2 11.5 14.3 ...
## $ Definitive : num [1:800] 4 3.55 2.73 3.55 3.65 ...
## $ Expense : num [1:800] 48.9 72.1 85.2 56.6 64.6 63 40.8 65.4 37.3 63 ...
## $ Income : num [1:800] 1.61 2.07 2.84 1.55 2.32 2.1 1.69 2.18 1.71 2.1 ...
## $ Gas : num [1:800] 27.4 24.2 22.3 23.1 27.3 ...
## $ Course : chr [1:800] "Face-to-Face" "Virtual" "Face-to-Face" "Virtual" ...
## $ Law : chr [1:800] "Agree" "Agree" "Agree" "Agree" ...
## $ Economic : chr [1:800] "Regular" "Good" "Regular" "Bad" ...
## $ Race : chr [1:800] "Ethnic" "Ethnic" "Ethnic" "Ethnic" ...
## $ Region : chr [1:800] "North" "Center" "North" "Center" ...
## $ EMO1 : num [1:800] 1 4 3 4 2 3 2 3 4 2 ...
## $ EMO2 : num [1:800] 2 4 1 2 1 1 4 1 2 2 ...
## $ EMO3 : num [1:800] 2 1 3 3 2 4 2 4 3 3 ...
## $ EMO4 : num [1:800] 1 2 3 1 4 2 3 2 1 1 ...
## $ EMO5 : num [1:800] 4 1 2 2 2 2 1 1 2 2 ...
## $ GOAL1 : chr [1:800] "Strongly agree" "Undecided" "Agree" "Agree" ...
## $ GOAL2 : chr [1:800] "Agree" "Disagree" "Disagree" "Undecided" ...
## $ GOAL3 : chr [1:800] "Strongly agree" "Disagree" "Agree" "Strongly agree" ...
## $ Pre_STAT1 : num [1:800] 2 1 5 4 1 4 4 2 2 2 ...
## $ Pre_STAT2 : num [1:800] 4 1 1 3 4 1 2 3 3 5 ...
## $ Pre_STAT3 : num [1:800] 2 1 3 1 1 5 4 3 3 2 ...
## $ Pre_STAT4 : num [1:800] 5 1 1 2 2 3 2 3 2 4 ...
## $ Post_STAT1 : num [1:800] 4 5 5 3 5 2 3 3 2 5 ...
## $ Post_STAT2 : num [1:800] 5 1 2 2 3 3 2 3 2 3 ...
## $ Post_STAT3 : num [1:800] 2 3 3 4 3 5 5 4 5 4 ...
## $ Post_STAT4 : num [1:800] 2 3 3 5 4 4 3 5 5 1 ...
## $ Pre_IDARE1 : chr [1:800] "Quite a bit" "Quite a bit" "Quite a bit" "Little" ...
## $ Pre_IDARE2 : chr [1:800] "Little" "Little" "Little" "Nothing" ...
## $ Pre_IDARE3 : chr [1:800] "Quite a bit" "A lot" "Quite a bit" "Quite a bit" ...
## $ Pre_IDARE4 : chr [1:800] "Quite a bit" "Nothing" "Quite a bit" "Quite a bit" ...
## $ Pre_IDARE5 : chr [1:800] "Little" "Quite a bit" "Little" "Nothing" ...
## $ Post_IDARE1 : chr [1:800] "A lot" "A little" "Nothing" "Quite a bit" ...
## $ Post_IDARE2 : chr [1:800] "A lot" "Nothing" "Quite a bit" "A little" ...
## $ Post_IDARE3 : chr [1:800] "A little" "Quite a bit" "Nothing" "A lot" ...
## $ Post_IDARE4 : chr [1:800] "Quite a bit" "A lot" "Nothing" "Quite a bit" ...
## $ Post_IDARE5 : chr [1:800] "A lot" "Quite a bit" "Nothing" "A lot" ...
## $ PSICO1 : chr [1:800] "Frequently" "Frequently" "Sometimes" "Almost always" ...
## $ PSICO2 : chr [1:800] "Almost always" "Sometimes" "Sometimes" "Frequently" ...
## $ PSICO3 : chr [1:800] "Frequently" "Sometimes" "Sometimes" "Frequently" ...
## $ PSICO4 : chr [1:800] "Almost always" "Frequently" "Frequently" "Almost never" ...
## $ PSICO5 : chr [1:800] "Almost always" "Frequently" "Sometimes" "Sometimes" ...
Interpretación: La estructura confirma que la base de datos contiene 800 observaciones (filas) y 66 variables (columnas). Además, permite verificar si cada variable está definida como numérica (num), de texto (chr), o de otro tipo.
Listar la totalidad de los nombres que identifican a cada una de las columnas contenidas en el data frame.
names(datosCompleto) #A) Muestra los nombres de las columnas (variables).
## [1] "Observation" "ID" "Gender" "Like" "Age"
## [6] "Smoke" "Height" "Weight" "BMI" "School"
## [11] "SES" "Enrollment" "Score" "MotherHeight" "MotherAge"
## [16] "MotherCHD" "FatherHeight" "FatherAge" "FatherCHD" "Status"
## [21] "SemAcum" "Exam1" "Exam2" "Exam3" "Exam4"
## [26] "ExamAcum" "Definitive" "Expense" "Income" "Gas"
## [31] "Course" "Law" "Economic" "Race" "Region"
## [36] "EMO1" "EMO2" "EMO3" "EMO4" "EMO5"
## [41] "GOAL1" "GOAL2" "GOAL3" "Pre_STAT1" "Pre_STAT2"
## [46] "Pre_STAT3" "Pre_STAT4" "Post_STAT1" "Post_STAT2" "Post_STAT3"
## [51] "Post_STAT4" "Pre_IDARE1" "Pre_IDARE2" "Pre_IDARE3" "Pre_IDARE4"
## [56] "Pre_IDARE5" "Post_IDARE1" "Post_IDARE2" "Post_IDARE3" "Post_IDARE4"
## [61] "Post_IDARE5" "PSICO1" "PSICO2" "PSICO3" "PSICO4"
## [66] "PSICO5"
Interpretación:La salida desplegó las 66 etiquetas del data frame, permitiendo identificar con precisión la posición y sintaxis exacta de variables de interés como la columna 2 (ID), la columna 3 (Gender), la columna 6 (Smoke) o la columna de la nota del examen 3 (Exam3).
Extraer y filtrar un subconjunto específico de la tabla mediante la sintaxis [filas, columnas] para facilitar el análisis sobre una muestra acotada.
Muestra1 <- datosCompleto[1:10,2:7] # A) Un nuevo data frame
Muestra1
## # A tibble: 10 × 6
## ID Gender Like Age Smoke Height
## <chr> <chr> <chr> <dbl> <chr> <dbl>
## 1 SB11201910010435 Female TV 21.4 No 1.58
## 2 SB11201910004475 Male Network 21.1 Yes 1.6
## 3 SB11201910011427 Male Network 20.9 Yes 1.5
## 4 SB11201910041975 Male TV 18.4 Yes 1.53
## 5 SB11201910013623 Female TV 16.6 Yes 1.78
## 6 SB11201910038122 Female Network 16.0 No 1.65
## 7 SB11201910037905 Female TV 19.3 Yes 1.73
## 8 SB11201910038140 Female TV 18.6 Yes 1.53
## 9 SB11201910038005 Female TV 17.0 Yes 1.64
## 10 SB11201910037919 Male TV 19.7 Yes 1.52
Salida obtenida: Una tabla reducida que muestra únicamente las primeras 10 filas (de la 1 a la 10) y 6 columnas (de la 2 a la 7: ID, Gender, Like, Age, Smoke y Height).
Interpretación: Se aisló correctamente una submuestra de 10 estudiantes y 6 variables. Esta técnica redujo el tamaño de trabajo del 100% de la base (800 registros) a solo el 1.25% de los datos, permitiendo verificar la manipulación de filas y columnas sin alterar el archivo original.
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
#Including Plots
Se construyen las tablas de distribución de frecuencias absolutas y relativas para explorar la distribución de variables categóricas (como el sexo y la condición de fumar) tanto de manera individual como conjunta (tablas de contingencia) dentro de una muestra acotada de 100 observaciones.
Muestra <- datosCompleto[1:100,]
#A) Definiendo y convirtiendo en factor
Sexo <- as.factor(Muestra$Gender)
#B) Calcular tabla de frecuencias
Tabla1 <- table(Sexo)
Tabla1
## Sexo
## Female Male
## 49 51
# porcentaje de mujeres
(49/100)*100
## [1] 49
#A) Definiendo y convirtiendo en factor
Fuma <- as.factor(Muestra$Smoke)
#B) Calcular tabla de frecuencias
Tabla2 <- table(Fuma)
Tabla2
## Fuma
## No Yes
## 45 55
#B) Tabla de frecuencias
Tabla3 <- table(Sexo, Fuma)
Tabla3
## Fuma
## Sexo No Yes
## Female 21 28
## Male 24 27
Salida obtenida: Tabla1: Frecuencia de la variable Sexo (ej. Female: 49, Male: 51). Porcentaje calculado: 49% de participación femenina en la muestra.
Tabla2: Frecuencia de la variable Fuma clasificando los niveles de consumo de tabaco (ej. Heavy, Never, Occas, Reg).
Tabla3: Matriz cruzada de dos entradas entre Sexo y Fuma.
Interpretación: La conversión a factor permitió clasificar correctamente las variables cualitativas. Las tablas revelan la distribución exacta de hombres y mujeres en la muestra de 100 estudiantes, así como sus hábitos de fumar de forma aislada y cruzada.
El objetivo de análisis es visualizar gráficamente las distribuciones de frecuencias absolutas y las relaciones entre variables categóricas mediante diagramas de barras personalizados con ggplot2, incorporando etiquetas de conteo, esquemas de color y divisiones por facetas.
ggplot(Muestra, aes(x = Sexo)) + #1
#geom_bar() + #2
geom_bar(width=0.5, colour="purple", fill="purple") + #2
labs(x="Sexo",y= "Frecuencia") + #3
ylim(c(0,60)) + #4
#xlim(c(0,300)) + #4
ggtitle("Diagrama de barras") + #5
# theme_bw() + #6
theme_bw(base_size = 12) + #6
#coord_flip() + #7
geom_text(aes(label=..count..), stat='count', #8
position=position_dodge(0.9),
vjust=-0.5,
size=5.0
) +
facet_wrap(~"Variable Sexo") #9
## Warning: The dot-dot notation (`..count..`) was deprecated in ggplot2 3.4.0.
## ℹ Please use `after_stat(count)` instead.
## This warning is displayed once per session.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
ggplot(Muestra, aes(Fuma, fill=Sexo)) +
geom_bar(position="dodge",colour="black") +
labs(x= "Fuma", y="Frecuencias", fill="Sexo") +
ylim(c(0,30)) +
#xlim(c(0,300)) +
ggtitle("Diagrama de barras") +
#theme_bw() +
theme_bw(base_size = 12) +
#coord_flip() +
#guides(fill=FALSE)+ #8
scale_fill_manual(values = c("pink","skyblue")) + #9
geom_text(aes(label=..count..), stat='count', #10
position=position_dodge(0.9),
vjust=-0.5,
size=5.0
)+
facet_wrap(~"Sexo por fumadores y no fumadores") #11
ggplot(Muestra, aes(Sexo, fill=Fuma)) +
geom_bar(position="dodge",colour="black") +
labs(x= "Fuma", y="Frecuencias", fill="Sexo") +
ylim(c(0,30)) +
#xlim(c(0,300)) +
ggtitle("Diagrama de barras") +
#theme_bw() +
theme_bw(base_size = 12) +
#coord_flip() +
#guides(fill=FALSE)+ #8
scale_fill_manual(values = c("green","yellow")) + #9
geom_text(aes(label=..count..), stat='count', #10
position=position_dodge(0.9),
vjust=-0.5,
size=5.0
)+
facet_wrap(~"Fuma por Genero") #11
Salida obtenida: Tres gráficos de barras detallado: el primero muestra
la barra morada de frecuencias de Sexo; el segundo y el tercero muestran
barras agrupadas por categorías cruzadas con leyendas de color y valores
numéricos sobre cada barra.
Interpretación del Gráfico 1 (Variable Sexo): De los 100 estudiantes en la muestra, 51 son hombres y 49 son mujeres, observándose una distribución prácticamente equitativa en la variable Sexo.
Interpretación del Gráfico 2 (Sexo por fumadores y no fumadores): En la categoría de no fumadores (Never), se encuentran 28 mujeres y 23 hombres; mientras que entre los fumadores regulares (Reg), se registran 7 hombres frente a 4 mujeres.
Interpretación del Gráfico 3 (Fuma por Genero): Dentro del grupo de las mujeres, la mayoría (28 estudiantes) nunca ha fumado (Never), mientras que solo 4 se identifican como fumadoras regulares (Reg). Por parte de los hombres, 23 declaran no haber fumado nunca y 7 son fumadores regulares
Objetivo del análisis: Extraer y transformar a un formato estrictamente numérico la variable cuantitativa Exam3 a partir de una muestra de 100 observaciones (Muestra2), con el fin de preparar los datos para la extracción de estadísticas descriptivas.
Muestra2 <- datosCompleto[1:100,]
x <- as.numeric(Muestra2$Exam3) # A) Convirtiendo la variable a numérica
x
## [1] 5.0 3.7 2.0 5.0 5.0 4.2 3.5 4.6 3.8 4.3 3.0 3.8 3.4 3.3 3.5 4.5 3.6 4.0
## [19] 3.4 4.0 4.2 3.5 3.7 4.0 4.0 3.2 2.9 2.9 3.0 3.3 2.8 2.4 3.8 3.3 3.2 2.2
## [37] 2.6 3.2 3.3 1.2 4.2 2.4 5.0 2.8 3.0 3.8 3.2 1.5 2.6 3.8 3.2 3.3 1.4 3.8
## [55] 1.4 3.6 3.6 2.4 2.8 3.1 2.4 1.8 1.6 3.3 4.4 1.0 4.5 2.0 4.2 4.2 3.1 2.3
## [73] 2.6 2.7 2.4 2.2 2.8 2.4 1.9 2.4 1.7 2.9 2.4 2.2 2.8 3.2 3.1 2.7 2.5 3.5
## [91] 3.3 2.1 3.3 2.1 3.7 5.0 3.7 2.0 5.0 5.0
Salida obtenida: Un vector numérico x impreso en consola que contiene las notas o puntajes asignados a la variable Exam3 para los 100 registros.
Interpretación: La variable fue convertida exitosamente a tipo numérico (numeric), garantizando que se puedan realizar operaciones aritméticas y métricas inferenciales sin errores de formato.
Objetivo del análisis: Calcular las principales medidas de tendencia central (media, mediana), posición (cuartiles, percentiles), dispersión (mínimo, máximo, rango, varianza, desviación estándar) y forma (sesgo) para resumir cuantitativamente el comportamiento de la variable Exam3.
str(datosCompleto) #A) Estructura de los datos{}
## tibble [800 × 66] (S3: tbl_df/tbl/data.frame)
## $ Observation : num [1:800] 1 2 3 4 5 6 7 8 9 10 ...
## $ ID : chr [1:800] "SB11201910010435" "SB11201910004475" "SB11201910011427" "SB11201910041975" ...
## $ Gender : chr [1:800] "Female" "Male" "Male" "Male" ...
## $ Like : chr [1:800] "TV" "Network" "Network" "TV" ...
## $ Age : num [1:800] 21.4 21.1 20.9 18.4 16.6 ...
## $ Smoke : chr [1:800] "No" "Yes" "Yes" "Yes" ...
## $ Height : num [1:800] 1.58 1.6 1.5 1.53 1.78 1.65 1.73 1.53 1.64 1.52 ...
## $ Weight : num [1:800] 75 80 64 49 82 80 90 55 50 78 ...
## $ BMI : num [1:800] 30 31.2 28.4 20.9 25.9 ...
## $ School : chr [1:800] "Private" "Public" "Private" "Public" ...
## $ SES : chr [1:800] "Medium" "High" "High" "Low" ...
## $ Enrollment : chr [1:800] "Credit" "Scholarship" "Scholarship" "Credit" ...
## $ Score : num [1:800] 81 78 77 70 68 65 54 50 36 35 ...
## $ MotherHeight: chr [1:800] "Short_M" "Normal_M" "Normal_M" "Tall_M" ...
## $ MotherAge : num [1:800] 41 45 45 45 46 46 47 48 48 48 ...
## $ MotherCHD : num [1:800] 0 0 0 0 1 0 0 0 0 1 ...
## $ FatherHeight: chr [1:800] "Normal_F" "Short_F" "Tall_F" "Short_F" ...
## $ FatherAge : num [1:800] 40 43 44 45 45 46 46 48 48 49 ...
## $ FatherCHD : num [1:800] 1 1 1 2 1 1 1 1 1 1 ...
## $ Status : chr [1:800] "Distinguished" "Distinguished" "Distinguished" "Regular" ...
## $ SemAcum : num [1:800] 4.25 2.8 4.15 3.2 3.45 2.75 2.7 4.35 4.3 2.8 ...
## $ Exam1 : num [1:800] 1.5 2.3 3.4 2.5 3.1 3.8 5 4 2.5 2.4 ...
## $ Exam2 : num [1:800] 5 4.9 3.6 4.2 3.5 4.4 3 2.3 3.3 2.6 ...
## $ Exam3 : num [1:800] 5 3.7 2 5 5 4.2 3.5 4.6 3.8 4.3 ...
## $ Exam4 : num [1:800] 4.5 3.3 1.9 2.5 3 5 3.6 4.3 1.9 5 ...
## $ ExamAcum : num [1:800] 16 14.2 10.9 14.2 14.6 17.4 15.1 15.2 11.5 14.3 ...
## $ Definitive : num [1:800] 4 3.55 2.73 3.55 3.65 ...
## $ Expense : num [1:800] 48.9 72.1 85.2 56.6 64.6 63 40.8 65.4 37.3 63 ...
## $ Income : num [1:800] 1.61 2.07 2.84 1.55 2.32 2.1 1.69 2.18 1.71 2.1 ...
## $ Gas : num [1:800] 27.4 24.2 22.3 23.1 27.3 ...
## $ Course : chr [1:800] "Face-to-Face" "Virtual" "Face-to-Face" "Virtual" ...
## $ Law : chr [1:800] "Agree" "Agree" "Agree" "Agree" ...
## $ Economic : chr [1:800] "Regular" "Good" "Regular" "Bad" ...
## $ Race : chr [1:800] "Ethnic" "Ethnic" "Ethnic" "Ethnic" ...
## $ Region : chr [1:800] "North" "Center" "North" "Center" ...
## $ EMO1 : num [1:800] 1 4 3 4 2 3 2 3 4 2 ...
## $ EMO2 : num [1:800] 2 4 1 2 1 1 4 1 2 2 ...
## $ EMO3 : num [1:800] 2 1 3 3 2 4 2 4 3 3 ...
## $ EMO4 : num [1:800] 1 2 3 1 4 2 3 2 1 1 ...
## $ EMO5 : num [1:800] 4 1 2 2 2 2 1 1 2 2 ...
## $ GOAL1 : chr [1:800] "Strongly agree" "Undecided" "Agree" "Agree" ...
## $ GOAL2 : chr [1:800] "Agree" "Disagree" "Disagree" "Undecided" ...
## $ GOAL3 : chr [1:800] "Strongly agree" "Disagree" "Agree" "Strongly agree" ...
## $ Pre_STAT1 : num [1:800] 2 1 5 4 1 4 4 2 2 2 ...
## $ Pre_STAT2 : num [1:800] 4 1 1 3 4 1 2 3 3 5 ...
## $ Pre_STAT3 : num [1:800] 2 1 3 1 1 5 4 3 3 2 ...
## $ Pre_STAT4 : num [1:800] 5 1 1 2 2 3 2 3 2 4 ...
## $ Post_STAT1 : num [1:800] 4 5 5 3 5 2 3 3 2 5 ...
## $ Post_STAT2 : num [1:800] 5 1 2 2 3 3 2 3 2 3 ...
## $ Post_STAT3 : num [1:800] 2 3 3 4 3 5 5 4 5 4 ...
## $ Post_STAT4 : num [1:800] 2 3 3 5 4 4 3 5 5 1 ...
## $ Pre_IDARE1 : chr [1:800] "Quite a bit" "Quite a bit" "Quite a bit" "Little" ...
## $ Pre_IDARE2 : chr [1:800] "Little" "Little" "Little" "Nothing" ...
## $ Pre_IDARE3 : chr [1:800] "Quite a bit" "A lot" "Quite a bit" "Quite a bit" ...
## $ Pre_IDARE4 : chr [1:800] "Quite a bit" "Nothing" "Quite a bit" "Quite a bit" ...
## $ Pre_IDARE5 : chr [1:800] "Little" "Quite a bit" "Little" "Nothing" ...
## $ Post_IDARE1 : chr [1:800] "A lot" "A little" "Nothing" "Quite a bit" ...
## $ Post_IDARE2 : chr [1:800] "A lot" "Nothing" "Quite a bit" "A little" ...
## $ Post_IDARE3 : chr [1:800] "A little" "Quite a bit" "Nothing" "A lot" ...
## $ Post_IDARE4 : chr [1:800] "Quite a bit" "A lot" "Nothing" "Quite a bit" ...
## $ Post_IDARE5 : chr [1:800] "A lot" "Quite a bit" "Nothing" "A lot" ...
## $ PSICO1 : chr [1:800] "Frequently" "Frequently" "Sometimes" "Almost always" ...
## $ PSICO2 : chr [1:800] "Almost always" "Sometimes" "Sometimes" "Frequently" ...
## $ PSICO3 : chr [1:800] "Frequently" "Sometimes" "Sometimes" "Frequently" ...
## $ PSICO4 : chr [1:800] "Almost always" "Frequently" "Frequently" "Almost never" ...
## $ PSICO5 : chr [1:800] "Almost always" "Frequently" "Sometimes" "Sometimes" ...
min(x) #B) Mínimo
## [1] 1
max(x) #C) Máximo
## [1] 5
range(x) #D) Obtenemos (min, max)
## [1] 1 5
length(x) #E) Tamaño
## [1] 100
sum(x) #F) Suma los valores de los datos
## [1] 317.6
mean(x) #G) Media aritmética
## [1] 3.176
median(x) #H) Mediana
## [1] 3.2
var(x) #I) Varianza muestral
## [1] 0.8885091
sqrt(var(x)) #J) Desviación estándar muestral (una forma)
## [1] 0.9426076
sd(x) #K) Desviación estándar muestral (otra forma)
## [1] 0.9426076
skewness(x) #L) Sesgo
## [1] 0.01846742
quantile(x, probs=0.80) #M) 80-ésimo percentil o percentil 85
## 80%
## 4
quantile(x, probs=0.25) #N) Primer cuartil o 25-ésimo percentil
## 25%
## 2.4
quantile(x, probs=0.50) #O) Segundo cuartil o 50-ésimo percentil o mediana
## 50%
## 3.2
quantile(x, probs=0.75) #P) Tercer cuartil o 75-ésimo percentil
## 75%
## 3.8
quantile(x, probs=0.85) #M) 80-ésimo percentil o percentil 85
## 85%
## 4.2
quantile(x, probs=0.25) #N) Primer cuartil o 25-ésimo percentil
## 25%
## 2.4
quantile(x, probs=0.50) #O) Segundo cuartil o 50-ésimo percentil o mediana
## 50%
## 3.2
quantile(x, probs=0.75) #P) Tercer cuartil o 75-ésimo percentil
## 75%
## 3.8
Salida obtenida: Valores numéricos puntuales correspondientes al rango de notas, la media, la desviación estándar, el grado de asimetría y los valores límite correspondientes a los percentiles requeridos.
Interpretación: El 25% de los estudiantes obtuvo una calificación igual o inferior a 2.8 en el examen 3. El 50% de las notas alcanzadas se ubica en un valor menor o igual a 3.2 (mediana). Por otro lado, el 75% de los alumnos obtuvo una nota menor o igual a 3.8, mientras que el 80% alcanzó una calificación igual o inferior a 4.0.