Skip to content

Instantly share code, notes, and snippets.

View mine-cetinkaya-rundel's full-sized avatar

Mine Cetinkaya-Rundel mine-cetinkaya-rundel

View GitHub Profile
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / in-utero-average.R
Created June 24, 2020 09:02
Calculating average measurement in utero (inspired by a question on RLadies Slack)
library(tidyverse)
packageVersion("dplyr")
library(lubridate)
library(glue)
set.seed(1234)
children <- tribble(
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / shinydashboard-dynamic-sidebar-menu-items.R
Last active April 19, 2020 15:39
Dynamic sidebar menu items in Shiny dashboard
library(shiny)
library(shinydashboard)
# ui ---------------------------------------------------------------------------
ui <- dashboardPage(
# title ----
dashboardHeader(title = "Test Application"),
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / nyt-first-said.R
Created April 13, 2020 08:13
NYT First Said counts, labelling highest
library(rtweet)
library(tidyverse)
library(glue)
rt <- get_timeline(
user = "@NYT_first_said",
n = 18000
)
rt <- rt %>%
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / theming_rprofile.R
Last active May 15, 2024 15:41
Add to your .Rprofile to change RStudio theme based on hour of the day (dark mode 8pm-6am, light mode 7am-7pm)
# theme options based on hour of day -------------------------------------------
# based on https://github.com/rstudio/rstudio/issues/1579
setHook("rstudio.sessionInit", function(chooseTheme) {
if (chooseTheme) {
if (as.numeric(format(as.POSIXct(Sys.time(), format = "%H:%M:%S"), "%H")) %in% c(0:5, 21:23)) {
if (rstudioapi::getThemeInfo()$editor != "Solarized Dark") rstudioapi::applyTheme("Solarized Dark")
} else {
if (rstudioapi::getThemeInfo()$editor != "Solarized Light") rstudioapi::applyTheme("Solarized Light")
}
}
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / uncount.R
Created February 5, 2020 15:11
Example using tidyr::uncount()
# data source ------------------------------------------------------------------
# Are federal laws on gun ownership too strict? Not strict enough? Or just about right?
# http://www.surveyusa.com/client/PollReport.aspx?g=e2893631-b41f-40e1-a049-86e0849670ce
# load packages ----------------------------------------------------------------
library(tidyverse)
# frequency table --------------------------------------------------------------
freq_table <- tribble(
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / shiny-intro.R
Last active July 31, 2020 10:47
Intro walkthrough in Shiny app
library(shiny)
library(rintrojs)
ui <- fluidPage(
introjsUI(), # Must include UI
titlePanel("Hello Shiny!"),
sidebarLayout(
sidebarPanel(
sliderInput(inputId = "bins",
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / door.R
Last active September 21, 2019 22:50
Needed to put my name on my door, naturally I used #rstats for it
# load packages ----------------------------------------------------------------
library(tidyverse)
library(patchwork)
# m ----------------------------------------------------------------------------
m_df <- tribble(
~column, ~height,
"h1", 50,
library(tidyr)
library(dplyr, warn.conflicts = FALSE)
library(purrr)
x <- tibble(
v1 = list(NULL),
v2 = list("something"),
v3 = list(NULL)
)
---
title: "test"
output: html_vignette
---
```{r error=TRUE, comment = "#>", collapse = TRUE}
x
x()
```
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / lesson_emojis.Rmd
Last active November 23, 2018 19:16
Extracting emojis for each lesson
---
title: "Lesson emojis"
author: "Mine Çetinkaya-Rundel"
date: "11/21/2018"
output:
html_document:
highlight: pygments
theme: cerulean
---