Skip to content

Instantly share code, notes, and snippets.

View TimTeaFan's full-sized avatar

Tim Tiefenbach TimTeaFan

View GitHub Profile
@TimTeaFan
TimTeaFan / d.R
Created April 18, 2021 11:05
combine and keep attributes of same length
l1 <- structure(list(x = 1), attr = 1)
l2 <- structure(list(y = 2), attr = 2)
d <- function(...) {
dots <- match.call(expand.dots = FALSE)$...
attr_ls <- lapply(dots, function(x) attributes(get(as.character(x))))
attr_ls <- lapply(purrr::transpose(attr_ls), unlist)
out <- c(...)
@TimTeaFan
TimTeaFan / shiny_overlay.R
Created September 18, 2020 21:30
Shiny Overlay Page
# Adaption of w3schools overlay page
# https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_overlay_text
library(shiny)
library(shinyjs)
# Overlay js function
jsCode <- "
shinyjs.overlay_on = function() {
@TimTeaFan
TimTeaFan / head_count.R
Created July 3, 2020 13:33
Calculate Head Count over Month based on start / end date.
library(tidyverse)
library(lubridate)
dat <- tribble(~id, ~start, ~end,
0102, "2018-01-02", "2018-01-07",
2190, "2018-01-01", "2018-03-06",
2432, "2018-01-03", "2018-05-07",
0121, "2018-01-03", "2018-02-04",
0121, "2018-01-02", "2018-01-15",
)