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 packages ---------------------------------------------------------------- | |
library(ggmap) # for geocoding cities, need v2.7 from https://github.com/dkahle/ggmap | |
library(fields) # for finding distance between two points | |
library(maps) # for world map | |
library(geosphere) # for connecting dots | |
# geocode cities lived --------------------------------------------------------- | |
ist <- geocode("Istanbul, Turkey") | |
nyc <- geocode("New York, NY, USA") | |
lax <- geocode("Los Angeles, CA, USA") |
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) | |
# mutate ----------------------------------------------------------------------- | |
iris %>% | |
mutate( | |
Sepal.Length_cat = ifelse(Sepal.Length < mean(Sepal.Length), "below mean", "at or above mean"), | |
Sepal.Width_cat = ifelse(Sepal.Width < mean(Sepal.Width), "below mean", "at or above mean"), | |
Petal.Length_cat = ifelse(Petal.Length < mean(Petal.Length), "below mean", "at or above mean"), | |
Petal.Width_cat = ifelse(Petal.Width < mean(Petal.Width), "below mean", "at or above mean") | |
) %>% |
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
--- | |
title: "Lesson emojis" | |
author: "Mine Çetinkaya-Rundel" | |
date: "11/21/2018" | |
output: | |
html_document: | |
highlight: pygments | |
theme: cerulean | |
--- |
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
--- | |
title: "test" | |
output: html_vignette | |
--- | |
```{r error=TRUE, comment = "#>", collapse = TRUE} | |
x | |
x() | |
``` |
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(tidyr) | |
library(dplyr, warn.conflicts = FALSE) | |
library(purrr) | |
x <- tibble( | |
v1 = list(NULL), | |
v2 = list("something"), | |
v3 = list(NULL) | |
) |
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 packages ---------------------------------------------------------------- | |
library(tidyverse) | |
library(patchwork) | |
# m ---------------------------------------------------------------------------- | |
m_df <- tribble( | |
~column, ~height, | |
"h1", 50, |
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(shiny) | |
library(rintrojs) | |
ui <- fluidPage( | |
introjsUI(), # Must include UI | |
titlePanel("Hello Shiny!"), | |
sidebarLayout( | |
sidebarPanel( | |
sliderInput(inputId = "bins", |
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
# 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( |
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
# 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") | |
} | |
} |
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(rtweet) | |
library(tidyverse) | |
library(glue) | |
rt <- get_timeline( | |
user = "@NYT_first_said", | |
n = 18000 | |
) | |
rt <- rt %>% |