library(tidyverse)
simple_data <- tibble(
group = factor(rep(c("A", "B"), each = 15)),
subject = 1:30,
score = c(rnorm(15, 40, 20), rnorm(15, 60, 10))
)
simple_data_se <- simple_data %>%
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) | |
# https://twitter.com/buddyherms/status/1576966150680121344 -------------- | |
# PROs: at, by, and regexp examples | |
# CONs: quite simple | |
vt_census <- tidycensus::get_decennial( | |
geography = "block", | |
state = "VT", |
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
f1 <- function(n) { | |
x <- numeric() | |
for (i in 1:n) { | |
x <- c(x, i) | |
} | |
x | |
} | |
f1.5 <- function(n) { | |
x <- numeric() |
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(diamonds, package = "ggplot2") | |
# Most straightforward | |
diamonds$ppc <- diamonds$price / diamonds$carat | |
# Avoid repeating diamonds | |
diamonds$ppc <- with(diamonds, price / carat) | |
# The inspiration for dplyr's mutate | |
diamonds <- transform(diamonds, ppc = price / carat) |
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) | |
auth_setup_default() | |
json <- search_tweets("#rstats", n = 5000, include_rts = FALSE, parse = FALSE)[1:5] | |
tweets <- tibble(json = json) %>% | |
unnest_wider(json) %>% | |
select(statuses) %>% | |
unnest_longer(statuses) %>% |
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(ggplot2) | |
x <- c("بقرة", "دجاج", "حصان") | |
df <- data.frame(x = x, y = 1:3) | |
labels_rtl <- function(x) paste0("\u202B", x) | |
ggplot(df, aes(x, y)) + | |
geom_point() + | |
scale_x_discrete(labels = labels_rtl) + |
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
# need + validate ----------------------------------------------------------- | |
validate( | |
need( | |
mzfinder::check_mzr_object(ms_object$mzr_connection), | |
"Wasn't able to connect to MS file" | |
) | |
) | |
validate( | |
need(!is.null(input$ppm_input), "ppm_input must not be null"), | |
need(input$ppm_input > 0L, "ppm_input must be > 0") |
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
# Code for quick exploration of | |
# https://github.com/rfordatascience/tidytuesday/tree/master/data/2020/2020-05-26 | |
# Video at https://youtu.be/kHFmtKCI_F4 | |
library(tidyverse) | |
cocktails <- readr::read_csv("boston_cocktails.csv") | |
# Are name and row_id equivalent? ----------------------------------------- |
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(dplyr, warn.conflicts = FALSE) | |
library(gapminder) | |
probs <- c(0.1, 0.5, 0.9) | |
gapminder %>% | |
group_by(continent) %>% | |
summarise( | |
probs = probs, | |
across(is.numeric & !year, ~ quantile(.x, probs)) | |
) |
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
#!/bin/bash | |
# | |
# Installs the latest RStudio daily desktop build for OSX/macOS and Ubuntu(amd64) | |
# | |
# https://support.rstudio.com/hc/en-us/articles/203842428-Getting-the-newest-RStudio-builds | |
set -e | |
install_macos_daily() { | |
REDIRECT_URL="https://www.rstudio.org/download/latest/daily/desktop/mac/RStudio-latest.dmg" | |
echo "Discovering daily build from: ${REDIRECT_URL}" | |
# Perform a HEAD request to find the redirect target. We use the name of the |
NewerOlder