Importar Datos

library(readxl)
VA2019CAMPUS <- read_excel("F:/MEA2021/Primera presencialidad 27032021/Datos clase 1/VA2019CAMPUS.xlsx")
attach(VA2019CAMPUS) #función que adjunta los datos al programa
library(readxl)
DatapromRC <- read_excel("F:/MEA2021/Primera presencialidad 27032021/Datos clase 1/DatapromRC.xlsx")

Cálculo de estadisticas básicas

library(moments)
summary(PLCSABERPRO) #note que ya no tendremos que separar por $, dado la función attach
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##      65     125     144     145     164     224
mean(PLCSABERPRO)
## [1] 145.0013
median(PLCSABERPRO)
## [1] 144
sd(PLCSABERPRO)
## [1] 27.20463
variance <- function (PLCSABERPRO)   
sum((PLCSABERPRO-mean(PLCSABERPRO))^2)/(length(PLCSABERPRO)-1) #escrita como una funcion
variance(PLCSABERPRO)
## [1] 740.0917
skewness(PLCSABERPRO) #nos da el valor de la asimetria de los datos de la variable x
## [1] 0.1139881
kurtosis(PLCSABERPRO) #nos da el achatamiento de la distribucion de los datos de la variable x.
## [1] 2.700964
quantile(PLCSABERPRO) #Muestra los cuartiles de la variable x
##   0%  25%  50%  75% 100% 
##   65  125  144  164  224
quantile(PLCSABERPRO, c(.35, .60, .98))  #Muestra los percentiles al 35, 60 y 96% de la variable x
##    35%    60%    98% 
## 133.60 152.00 201.08

Tablas

library(plyr)
library(kableExtra)
library(knitr)
resumen <-ddply(VA2019CAMPUS, .(Campus, Programa), summarise, 
                PRCSABERPRO=mean(PRCSABERPRO, na.rm = TRUE))
resumen %>%
  kbl() %>%
  kable_classic_2(full_width = F)
Campus Programa PRCSABERPRO
Bucaramanga Adm FinancieraBUC 155.0000
Bucaramanga BacteriologiaBUC 161.7500
Bucaramanga ContaduriaBUC 146.3889
Bucaramanga DerechoBUC 137.2174
Bucaramanga EnfermeriaBUC 139.4500
Bucaramanga FisioterapiaBUC 147.5000
Bucaramanga FonoaudiologiaBUC 144.6250
Bucaramanga Ing AmbientalBUC 155.8000
Bucaramanga Ing CivilBUC 164.1867
Bucaramanga Ing ElectronicaBUC 152.0000
Bucaramanga Ing IndustrialBUC 158.0000
Bucaramanga InstrumentaciónBUC 141.1481
Bucaramanga Intrumentacion BOG 137.2353
Bucaramanga MedicinaBUC 151.0000
Bucaramanga MercadeoBUC 134.7500
Bucaramanga MicrobiologiaBUC 167.4667
Bucaramanga NegociosBUC 142.5556
Bucaramanga PsicologiaBUC 130.5789
Bucaramanga TerapiaBUC 131.6000
Bucaramanga VeterinariaBUC 149.9412
Cucuta Adm FinancieraCUC 149.6316
Cucuta BacteriologiaCUC 135.8182
Cucuta Comercio ExtCUC 147.8182
Cucuta DerechoCUC 147.6667
Cucuta EnfermeriaCUC 130.4138
Cucuta FisioterapiaCUC 143.3830
Cucuta Ing IndustrialCUC 149.7917
Cucuta Ing SistemasCUC 143.3333
Cucuta MedicinaCUC 151.5263
Cucuta MercadeoCUC 131.0769
Cucuta PsicologiaCUC 149.3333
Cucuta TerapiaCUC 131.7368
Valledupar Adm FinancieraVAL 132.2174
Valledupar BacteriologiaVAL 143.9000
Valledupar DerechoVAL 121.5172
Valledupar FisioterapiaVAL 121.3929
Valledupar Ing IndustrialVAL 140.9556
Valledupar PsicologiaVAL 117.3158
Valledupar VeterinariaVAL 147.5000

Distribución de frecuencia

library(fdth)
dist1 <- fdt(VA2019CAMPUS $ PLCSABERPRO,breaks="Sturges") 
dist1
##       Class limits   f   rf rf(%)  cf  cf(%)
##    [64.35,79.0673)   5 0.01  0.63   5   0.63
##  [79.0673,93.7845)  11 0.01  1.38  16   2.01
##  [93.7845,108.502)  51 0.06  6.40  67   8.41
##  [108.502,123.219) 120 0.15 15.06 187  23.46
##  [123.219,137.936) 135 0.17 16.94 322  40.40
##  [137.936,152.654) 162 0.20 20.33 484  60.73
##  [152.654,167.371) 147 0.18 18.44 631  79.17
##  [167.371,182.088)  93 0.12 11.67 724  90.84
##  [182.088,196.805)  48 0.06  6.02 772  96.86
##  [196.805,211.523)  20 0.03  2.51 792  99.37
##   [211.523,226.24)   5 0.01  0.63 797 100.00
range(PLCSABERPRO) #observamos el rango de duración, en nuestro caso, va de 3 a 25
## [1]  65 224

Gráficos estadísticos descriptivos

plot(dist1, type="cfp") #poligono de frecuencias acumulado

hist(VA2019CAMPUS $ PLCSABERPRO,xlab="Puntajes",ylab="frecuencia",main="Histograma PLC", labels = T, ylim=c(0,250), col="green3")

hist(VA2019CAMPUS $ PRCSABERPRO,xlab="Puntajes",ylab="frecuencia",main="Histograma PRC", labels = T, ylim=c(0,150), col="green3")

Promedio2<-data.frame(Prom = Promedio2)

library(lessR)

PieChart(Prom, hole = 0, values = "%", data = Promedio2,
         fill = c("gray62", "#F5C710", "#28E2E5"), main = "")

library(ggplot2)
ggplot(data=VA2019CAMPUS, aes(PLCSABERPRO,fill=Género)) +
  geom_density(alpha=0.7) 

ggplot(data=VA2019CAMPUS, aes(PLCSABERPRO,fill=Plantel)) +
  geom_density(alpha=0.7)

ggplot(data=VA2019CAMPUS, aes(PLCSABERPRO,fill=Estrato2)) +
  geom_density(alpha=0.7)

ggplot(data=VA2019CAMPUS, aes(PLCSABERPRO,fill=Promedio2)) +
  geom_density(alpha=0.7)

library(plotly)
plot_ly(data=VA2019CAMPUS, x = ~Programa, y = ~PLCSABERPRO, color = ~Programa, type = "box")
graph <- ggplot(data = VA2019CAMPUS,
                aes(x = PLCSABER11,
                    y = PLCSABERPRO,
                    label=Género,color=Programa)) +
  geom_point(shape = 23,
             size = 2) +
  xlab("PLCSABER11") +
  ylab("PLCSABERPRO") +
  geom_vline(xintercept = 50,
             linetype = "dashed") +
  geom_hline(yintercept = 150,
             linetype = "dashed") +
  theme_classic()+ stat_smooth()


ggplotly(
  graph,
  tooltip = c("PLCSABER11",
              "PLCSABERPRO",
              "VA2019CAMPUS", "Programa", "Género"))

print(sessionInfo(), local = FALSE)

library() Carga un paquete especifico de R
attach() permite adjuntar los datos de acuerdo a como fueron nombradas las variable
data() muestra conjunto de datos que contiene los paquetes que ha cargado
head() visualiza los titulos que contiene los datos
fdt() Función del paquete fdth que permite elaborar distribuciones de frecuencias
hist() elabora un histograma de frecuencias
palette() muestra los colores disponibles
par(mfrow=c(3,2)) permite dividir la ventana de graficos (3 filas, 2 columnas)
range() obtiene el rango de datos de un vector
sort() ordena los datos de la variable de interes en forma ascendente