This file contains hidden or 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
# animando | |
anim %>% animate(fps = 30, | |
nframes = 300, | |
detail = 10, | |
start_pause = 30, | |
end_pause = 30, | |
rewind = FALSE, | |
width = 400, | |
height = 400) |
This file contains hidden or 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
# crear animación | |
anim <- p + | |
# animacion con cambios en los estados del año | |
transition_states(year, | |
transition_length = 1, | |
state_length = 0, | |
wrap = FALSE) + | |
# permitir que los ejes cambien | |
view_follow() |
This file contains hidden or 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
# hacer objeto de grafica | |
p <- population_tidy %>% | |
ggplot(aes(ordering, group = country)) + | |
# utilizar geom_tile en lugar de geom_bar | |
geom_tile(aes(y = population10/2, | |
height = population10, | |
width = 0.9, fill=country), alpha = 0.9) + | |
# texto en las barras | |
geom_text(aes(y = population10, label = paste(as.character(round(population10)), 'M')), | |
vjust = 0.4, hjust = 0.55, size = 7) + |
This file contains hidden or 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
# crear datos tidy u ordenados | |
population_tidy <- population_data%>% | |
# filtrar para algunos paises de HispanoAmérica | |
filter(country %in% c('Argentina', | |
'Chile', | |
'Colombia', | |
'Ecuador', | |
'Mexico', | |
'Panama', | |
'Peru', |
This file contains hidden or 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
# descargar datos en https://www.gapminder.org/data/ | |
# escribir la ruta de los datos | |
path_to_data <- './population_total.csv' | |
# leer archivo csv | |
population_data <- read_csv(path_to_data) |
This file contains hidden or 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
library(tidyverse) | |
library(gganimate) | |
# devtools::install_github('bbc/bbplot') | |
library(bbplot) | |
library(ggthemes) | |
# Hecho por Rafa @GonzalezGouveia | |
# Con gusto para #DatosDeMiercoles, propuesto por @R4DS_es | |
cambio_lealtades <- readr::read_csv("https://raw.githubusercontent.com/cienciadedatos/datos-de-miercoles/master/datos/2019/2019-04-17/cambio_lealtades.csv") | |
# tiempo_pantalla <- readr::read_csv("https://raw.githubusercontent.com/cienciadedatos/datos-de-miercoles/master/datos/2019/2019-04-17/tiempo_pantalla.csv") |
This file contains hidden or 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
library(tidyverse) | |
library(ggthemes) | |
# Por Rafa @GonzalezGouvia | |
# leyendo directo de la página | |
partidos_fifa_copa_mundial_procesado <- readr::read_delim("https://raw.githubusercontent.com/cienciadedatos/datos-de-miercoles/master/datos/2019/2019-04-10/partidos.txt", delim = "\t") | |
# función auxiliar para extraer ultimo partido | |
quita_parentesis <- function(texto){ | |
as.integer(gsub("\\((.*)\\)", "\\1", texto)) |
This file contains hidden or 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
library(tidyverse) | |
# datos | |
# survey1: Cuál es el mayor uso que le das a R en tus análisis? | |
survey1 <- tibble( | |
# preguntas | |
option = c( | |
"Modelos", | |
"Gráficos", |
This file contains hidden or 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
def select_name(gender): | |
'''select a name based on gender''' | |
if gender == 'M': | |
name = np.random.choice(name_men_list) | |
elif gender == 'F': | |
name = np.random.choice(name_women_list) | |
return(name.split(' ')[0].capitalize()) | |
def create_table(n): |
This file contains hidden or 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
# set simulation parameters | |
low_age = 18 | |
high_age = 60 | |
low_height = 1.5 | |
high_height = 2 | |
decimals = 2 | |
genders = ['M', 'F'] |