Skip to content

Instantly share code, notes, and snippets.

parseFormula <- function(event_name, vars) {
m_formula <- paste0(
## Otavio/Anna change this since you are not using age as time scale!
"Surv(age_start, age_end, ", event_name, ") ~ ",
paste(vars, collapse = " + ")
)
as.formula(m_formula)
}
library(tidyverse)
getSameEpisodes <- function(h_visits_clean) {
visits_diff <- h_visits_clean %>%
## TODO Remove this if we want everyone
filter(date_visit >= "2016-01-01", date_visit <= "2020-12-31") %>%
arrange(perm_id, date_visit) %>%
group_by(perm_id) %>%
summarise(
date = date_visit,
library(tidyverse)
## Simple example dataset
time_on_study <- tibble(
id = 1:5,
start_followup = 0,
time_followup = c(2, 4, 3, 1, 3),
age_baseline = c(18, 30, 28, 20, 18),
event = factor(c(1, 0, 1, 1, 0), labels = c("Censored", "Event"))
)
git clone --depth=1 --single-branch
--branch emacs-27 https://github.com/emacs-mirror/emacs.git
cd emacs/
sudo apt install -y autoconf make gcc texinfo libgtk-3-dev libxpm-dev \
libjpeg-dev libgif-dev libtiff5-dev libgnutls28-dev libncurses5-dev \
libjansson-dev libharfbuzz-dev libharfbuzz-bin
./autogen.sh
library(splines)
library(dplyr)
library(readr)
library(tidyr)
library(ggplot2)
## Use your path
df <- read_csv("data.csv") %>%
select(fever, mean.anom.4w, water.safe)
library(dplyr)
## Create similar but simpler data frame to yours
df <- data.frame(
scenario = rep(1:3, 2),
year = rep(2010:2011, each = 3),
age_25_29 = rnorm(6),
age_30_34 = rnorm(6),
age_35_39 = rnorm(6)
)
@solmos
solmos / readNc.R
Last active September 17, 2020 16:02
library(tidyverse)
library(tidync)
readNcFiles <- function(files, lat_range = c(8, 37), lon_range = c(68, 98)) {
nc_list <- map(files, tidync)
names(nc_list) <- files
filterNc <- function(nc, lat_range = c(8, 37), lon_range = c(68, 98)) {
nc %>%
hyper_filter(LAT = between(LAT, lat_range[1], lat_range[2]),
readFireCounts <- function(file) {
fire_counts <- read_delim(file, delim = ";") %>%
rename(date = "ACQ_DATE") %>%
count(date) %>%
as_tibble()
dates_expanded <- seq(min(fire_counts$date), max(fire_counts$date), by = "days")
fires_full <- tibble(date = dates_expanded) %>%
left_join(fire_counts) %>%
mutate(
day = day(date),
## Scorekeeper bias in LEB Oro
library(tidyverse)
data_file <- "https://github.com/solmos/feb-data/raw/master/assists-leb-oro.csv"
assists_leb_oro <- read_csv(data_file)
# Players -----------------------------------------------------------------
ast_player <- assists_leb_oro %>%
# Elo Rating System
library(eurolig)
library(tidyverse)
library(lubridate)
load("data/results.rds")
# Helpers -----------------------------------------------------------------