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
library(tidyverse) | |
library(ggdist) | |
library(glue) | |
library(ggtext) | |
#url <- "https://www.fonasa.cl/sites/fonasa/datos-abiertos/bases-grd" | |
# Unzip file | |
unzip("raw-data/2022.zip", exdir = "raw-data/") |
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
library(tidyverse) | |
library(arrow) | |
url <- "https://datos.gob.cl/dataset/606ef5bb-11d1-475b-b69f-b980da5757f4/resource/ae6c9887-106d-4e98-8875-40bf2b836041/download/at_urg_respiratorio_semanal.parquet" | |
download.file(url, "raw-data/at_urg_respiratorio_semanal.parquet", mode = "wb") | |
df <- arrow::read_parquet("raw-data/at_urg_respiratorio_semanal.parquet") | |
influenza_hospitales <- df |> |
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
library(tidyverse) | |
library(finalfit) | |
library(survival) | |
melanoma <- boot::melanoma | |
melanoma <- melanoma |> | |
mutate( | |
status_os = if_else(status == 2, 0, | |
1 |
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
library(tidyverse) | |
library(ggdark) | |
urls <- c( | |
"https://repositoriodeis.minsal.cl/DatosAbiertos/VITALES/PUBLICADA%20NOV%202022%20MDC/Serie_Nacimientos_1992_2000.zip", | |
"https://repositoriodeis.minsal.cl/DatosAbiertos/VITALES/PUBLICADA%20NOV%202022%20MDC/Serie_Nacimientos_2001_2019.zip", | |
"https://repositoriodeis.minsal.cl/DatosAbiertos/VITALES/PUBLICADA%20NOV%202022%20MDC/DA_Nacimientos_2020.zip" | |
) | |
file_names <- c("nacimientos1.zip", "nacimientos2.zip", "nacimientos3.zip") |
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
# Load necessary libraries | |
library(tidyverse) # For data manipulation | |
library(survival) # For survival analysis | |
library(survminer) # For survival visualization | |
# Load TidyTuesday data for the 5th week of 2023 | |
data <- tidytuesdayR::tt_load(2023, week = 05) | |
# Extract relevant datasets | |
cats_uk <- data$cats_uk |
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
library(tidyverse) | |
url <- "https://sdmx.oecd.org/public/rest/data/OECD.ELS.HD,DSD_HEALTH_STAT@DF_LE,1.0/all?dimensionAtObservation=AllDimensions&format=csvfilewithlabels" | |
data <- read_csv(url) | |
first_last_values <- data |> | |
filter( | |
`Reference area` == "Chile", | |
Measure == "Life expectancy", |
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
library(tidyverse) | |
# URL for the dataset | |
url <- "https://raw.githubusercontent.com/github/innovationgraph/main/data/languages.csv" | |
# Read the dataset | |
data <- read_csv(url) | |
# Perform data manipulation and aggregation | |
p <- data |> |
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
library(httr) | |
library(jsonlite) | |
library(dplyr) | |
url <- "https://datos.gob.cl/api/3/action/datastore_search?resource_id=2c44d782-3365-44e3-aefb-2c8b8363a1bc" | |
# Option A: paginated download | |
download_paginated_data <- function(url) { | |
all_data <- list() | |
offset <- 0 |
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
set.seed(2006) | |
sample_sizes <- c(1, 10, 30, 1000) | |
nsims <- 10000 | |
# Helper function: Mean of one sample of X | |
one_mean <- function(n, p = c(0.8, 0.2)) { | |
mean(sample(0:1, n, replace = TRUE, prob = p)) | |
} |
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
def calculate_dv(rut): | |
rut_str = str(rut) | |
if len(rut_str) not in [7, 8]: | |
raise ValueError("The RUT must have 7 or 8 digits.") | |
rut_str = rut_str.zfill(8)[-8:] | |
rut_rev = list(map(int, list(rut_str[::-1]))) |
NewerOlder