Skip to content

Instantly share code, notes, and snippets.

View jthomasmock's full-sized avatar

Tom Mock jthomasmock

View GitHub Profile
---
format:
html:
theme:
- litera
execute:
echo: false
---
# Apache Arrow R questions on Stack Overfklow
library(arrow)
library(tidyverse)
library(slider)
ds <- arrow::open_dataset("data-parquet/", partitioning = "year")
all_plays <- ds |>
filter(!is.na(touchdown)) |>
filter(penalty == 0) |>
select(touchdown) |>
---
format:
revealjs:
slide-number: c/t
width: 1920
height: 1080
logo: "https://www.rstudio.com/wp-content/uploads/2018/10/RStudio-Logo-Flat.png"
footer: "[Get started with Quarto](https://rstudio-conf-2022.github.io/get-started-quarto/)"
theme: simple
echo: true
library(magick)
create_overlay <- function(img, overlay_color = "#00000060", out_file = NULL){
if(!("magick-image" %in% class(img))){
raw_img <- image_read(img)
} else if ("magick-image" %in% class(img)){
raw_img <- img
}
# get image dimensions
library(ggplot2)
library(readr)
library(tidyr)
library(dplyr)
library(lubridate)
library(stringr)
# https://github.com/jdjohn215/milwaukee-weather
ghcn <- read_csv("data/GHCN_USW00012921.csv") %>%
group_by(year) %>%
arrange(day_of_year) %>%
library(gt)
df_in <- dplyr::tibble(
col_val = c(11, 61, 11, 17),
tar_min = c(11, 45, 12, 11),
tar_max = c(22, 59, 21, 24),
label = c("Awake", "Light", "SWS (Deep)", "REM"),
time = c("0:50", "4:44", "0:51", "1:19")
)
library(gt)
library(gtExtras)
out_df <- tibble::tribble(
~rank, ~player, ~jersey, ~team, ~g, ~pass, ~pr_snaps, ~rsh_pct, ~prp, ~prsh,
1L, "Trey Hendrickson", "91", "CIN", 16, 495, 454, 91.7, 10.8, 83.9,
2L, "T.J. Watt", "90", "PIT", 15, 461, 413, 89.6, 10.7, 90.6,
3L, "Rashan Gary", "52", "GB", 16, 471, 463, 98.3, 10.4, 88.9,
4L, "Maxx Crosby", "98", "LV", 17, 599, 597, 99.7, 10, 91.8,
5L, "Matthew Judon", "09", "NE", 17, 510, 420, 82.4, 9.7, 73.2,
6L, "Myles Garrett", "95", "CLV", 17, 554, 543, 98, 9.5, 92.7,
``` r
library(tidyverse)
df <- palmerpenguins::penguins
ex_df <- df |>
group_by(species) |>
summarise(
n = n(),
mean = mean(body_mass_g, na.rm = TRUE),
---
format: html
---
::: {.panel-tabset}
## Plot
```{r my-plot, echo = FALSE}
library(ggplot2)
# adapted from https://glin.github.io/reactable/articles/cookbook/cookbook.html#nested-tables
library(dplyr)
data <- MASS::Cars93[18:47, ] %>%
mutate(ID = as.character(18:47), Date = seq(as.Date("2019-01-01"), by = "day", length.out = 30)) %>%
select(ID, Date, Manufacturer, Model, Type, Price)
sales_by_mfr <- group_by(data, Manufacturer) %>%
summarize(Quantity = n(), Sales = sum(Price)) |>