Skip to content

Instantly share code, notes, and snippets.

View avallecam's full-sized avatar
🎯
Focusing

Andree Valle Campos avallecam

🎯
Focusing
View GitHub Profile
@avallecam
avallecam / dot_whiskers_plot.md
Created November 1, 2024 20:53
create a dot whiskers plot with raw coeficient values, after passing one sample figure to chatgpt to generate a reprex
# Load libraries
library(tidyverse)

# Create data for the simple regression model (Panel A)
simple_data <- data.frame(
  Predictor = "Aware that humans can get TBD",
  Estimate = 0.3,
  SE = 0.1
)
@avallecam
avallecam / filter_continent_contacts.R
Last active September 20, 2024 10:40
filter countries in Africa with social contact survey data
library(socialmixr)
library(countrycode)
library(tidyverse)
# Get all countries names and... regex!!
all_countries <- countrycode::codelist
# Filter countries in the Africa continent
africa_countries <- all_countries %>%
select(continent, country.name.en,country.name.en.regex) %>%
@avallecam
avallecam / treedater.md
Last active September 3, 2024 12:50
phylogenetics: get the uncertainty for each node from a most-recent-common-ancertor (MRCA) estimation with {ape} and {treedater}
# pak::pak("treedater")

library(treedater)
#> Loading required package: ape
#> Loading required package: limSolve
library(tidyverse)
@avallecam
avallecam / cfr_riskratio.md
Last active August 13, 2024 13:45
Estimate the Case Fatality Risk Ratio to complement stratified CFR calculations

We can estimate the relative risk for the causal interpretation of CFR estimates (Lipsitch et al.)

two-by-two table

non-death death
44-younger 311 768
45+older 51 299

CFR (stratified)

@avallecam
avallecam / zika_model.md
Created August 2, 2024 18:22
example of zika model with simpler function
library(deSolve)   # Paquete deSolve para resolver las ecuaciones diferenciales
library(tidyverse) # Paquetes ggplot2 y dplyr de tidyverse
library(cowplot) # Paquete gridExtra para unir gráficos.
#> Warning: package 'cowplot' was built under R version 4.4.1
#> 
#> Attaching package: 'cowplot'
#> The following object is masked from 'package:lubridate':
#> 
#>     stamp
@avallecam
avallecam / casos_a_incidencia.R
Last active July 11, 2024 22:58
Usar {incidence2} y {dplyr} para adaptar datos de casos con {EpiNow2} y {cfr}
``` r
if(!require("pak")) install.packages("pak")
new_packages <- c(
"incidence2",
"outbreaks",
"tidyverse"
)
pak::pkg_install(new_packages)
@avallecam
avallecam / epiverse-list_columns.R
Last active May 31, 2024 14:04
functions from {epiparameter} and {epidemics} get tibble-friendly ouputs with list columns from nested data or multiple iterations made internally
``` r
library(tidyverse)
# epiparameter ------------------------------------------------------------
library(epiparameter)
# get set of epidist objects
epidist_input <- epiparameter::epidist_db(
disease = "covid",
@avallecam
avallecam / delays_cfr.R
Last active April 16, 2024 17:56
reporting delays bias CFR
``` r
# packages ----------------------------------------------------------------
library(tidyverse)
library(incidence2)
# input -------------------------------------------------------------------
onset <- tibble(
date = seq(ymd(20200101),ymd(20200104),1),
@avallecam
avallecam / python.Rmd
Last active February 9, 2024 20:10
quick start to use python within R
If I need to install python packages
```{python}
# install packages
pip install pandas
pip install matplotlib
```
I can install python (!!) and the packages in R using `{reticulate}`
@avallecam
avallecam / sampling-distribution-rowwise.md
Last active November 10, 2024 15:39
calculate the sampling distribution as demo for central limit theorem
# from py to R ------------------------------------------------------------

# to convert the a python notebook to Rmd file
# with https://pkgs.rstudio.com/rmarkdown/reference/convert_ipynb.html

# for one sample ----------------------------------------------------------

set.seed(123)