Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6a5234
commit 3e4fd6f
Showing
5 changed files
with
150 additions
and
440 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
--- | ||
title: "Ciencia de Datos usando R" | ||
output: html_notebook | ||
--- | ||
|
||
## Instalación | ||
|
||
```{r, eval = FALSE} | ||
install.packages("tidyverse") | ||
``` | ||
|
||
```{r} | ||
library(tidyverse) | ||
``` | ||
|
||
## Leer | ||
|
||
```{r} | ||
archivo <- read_csv("cuarto_grado.csv") | ||
archivo | ||
``` | ||
|
||
## Ordenar | ||
|
||
|
||
|
||
```{r} | ||
datos <- archivo %>% | ||
separate(nombre, into = c("apellido", "primer")) %>% | ||
separate(fecha, into = c("dia", "mes", "año"), convert = TRUE) %>% | ||
gather("materia", "puntos", "matematica", "ingles") | ||
datos | ||
``` | ||
|
||
Para obtener `%>%` use: [Ctrl] + [Shift] + m | ||
|
||
## Conocimiento | ||
|
||
¿Cual es el promedio actual por cada clase? | ||
|
||
```{r} | ||
datos %>% | ||
group_by(materia) %>% | ||
summarise(promedio = mean(puntos)) | ||
``` | ||
|
||
¿Cuales son los promedios de cada estudiante en matematica? | ||
|
||
```{r} | ||
datos %>% | ||
filter(materia == "matematica") %>% | ||
group_by(matricula, primer, apellido) %>% | ||
summarise(promedio = mean(puntos)) | ||
``` | ||
|
||
¿Cuales son los promedios de cada estudiante en ingles? | ||
|
||
```{r} | ||
datos %>% | ||
filter(materia == "ingles") %>% | ||
group_by(matricula, primer, apellido) %>% | ||
summarise(promedio = mean(puntos)) | ||
``` | ||
|
||
¿Quienes tienen los mejores promedios en ingles? | ||
|
||
```{r} | ||
datos %>% | ||
filter(materia == "ingles") %>% | ||
group_by(matricula, primer, apellido) %>% | ||
summarise(promedio = mean(puntos)) %>% | ||
arrange(desc(promedio)) %>% | ||
ungroup() %>% | ||
mutate(puesto = row_number()) | ||
``` | ||
|
||
¿Cual es la historia del ultimo lugar? | ||
|
||
```{r} | ||
datos %>% | ||
filter(matricula == 105, materia == "ingles") | ||
``` | ||
|
||
```{r} | ||
datos %>% | ||
filter(matricula == 105, materia == "ingles") %>% | ||
ggplot() + | ||
geom_line(aes(mes, puntos)) | ||
``` | ||
|
||
¿Cual es la historia de todos los alumnos? | ||
|
||
```{r} | ||
datos %>% | ||
filter(materia == "ingles") %>% | ||
ggplot() + | ||
geom_line(aes(mes, puntos, group = matricula)) | ||
#geom_line(aes(mes, puntos, group = matricula, color = apellido)) | ||
``` | ||
|
||
Formalizar la grafica | ||
|
||
```{r} | ||
datos %>% | ||
group_by(materia, mes) %>% | ||
summarise(promedio = mean(puntos)) %>% | ||
ggplot() + | ||
geom_line(aes(mes, promedio, group = materia, color = materia)) + | ||
labs(title = "Promedios mensuales por cada materia") | ||
``` | ||
|
||
Otras visualizaciones | ||
|
||
```{r} | ||
datos %>% | ||
ggplot() + | ||
geom_histogram(aes(puntos), binwidth = 10) + | ||
facet_wrap(~materia) | ||
``` | ||
|
||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.