Skip to content

Instantly share code, notes, and snippets.

Avatar
💫

Richard Iannone rich-iannone

💫
View GitHub Profile
@rich-iannone
rich-iannone / gh_issue_labels.R
Last active Mar 4, 2021
GitHub Issue Labels
View gh_issue_labels.R
library(usethis)
labels <-
c(
"Blocked (╥﹏╥)",
"Difficulty: ③ Advanced",
"Difficulty: ② Intermediate",
"Difficulty: ① Novice",
"Effort: ③ High",
"Effort: ② Medium",
@rich-iannone
rich-iannone / information_palmerpenguins.R
Last active Jan 19, 2021
A pointblank information report for the `peguins` dataset in the `palmerpenguins` package
View information_palmerpenguins.R
library(pointblank)
library(palmerpenguins)
informant_pp <-
create_informant(
read_fn = ~ palmerpenguins::penguins,
tbl_name = "penguins",
label = "The `penguins` dataset from the **palmerpenguins** 📦."
) %>%
info_columns(
@rich-iannone
rich-iannone / gtcars_rtf.R
Created Oct 5, 2020
An example of how to create a gt table and output an RTF file
View gtcars_rtf.R
library(gt)
library(tidyverse)
order_countries <- c("Germany", "Italy", "United States", "Japan")
best_gas_mileage_city <-
gtcars %>%
dplyr::arrange(desc(mpg_c)) %>%
dplyr::slice(1) %>%
dplyr::mutate(car = paste(mfr, model)) %>%
@rich-iannone
rich-iannone / tests_informant-revenue-postgres.R
Created Oct 1, 2020
A example of how to create an informant for the `revenue` table (hosted on a PostgreSQL DB)
View tests_informant-revenue-postgres.R
library(pointblank)
library(here)
library(intendo)
# Note: while this table is hosted on a database, the table can be obtained
# from the {intendo} package (https://github.com/rich-iannone/intendo)
informant_revenue_postgres <-
create_informant(
read_fn =
@rich-iannone
rich-iannone / reencode_utf8.R
Created Jul 25, 2020
A function that reencodes UTF-8 characters to code points
View reencode_utf8.R
reencode_utf8 <- function(x) {
# Ensure that we encode non-UTF-8 strings to UTF-8 in a
# two-step process: (1) to native encoding, and then
# (2) to UTF-8
if (Encoding(x) != 'UTF-8') {
x <- enc2utf8(x)
}
# Use `iconv()` to convert to UTF-32 (big endian) as
@rich-iannone
rich-iannone / gist:1da1ae7a7203958a0c5b1bd1d4b24017
Last active Oct 13, 2021
This gt code allows you to make a summary table based on the `pizzaplace` dataset.
View gist:1da1ae7a7203958a0c5b1bd1d4b24017
library(tidyverse)
library(paletteer)
library(gt)
pizzaplace %>%
mutate(type = case_when(
type == "chicken" ~ "chicken (pizzas with chicken as a major ingredient)",
type == "classic" ~ "classic (classical pizzas)",
type == "supreme" ~ "supreme (pizzas that try a little harder)",
type == "veggie" ~ "veggie (pizzas without any meats whatsoever)",
@rich-iannone
rich-iannone / pointblank_demo.R
Created Jan 30, 2020
A demonstration script that uses pointblank, logging, email notification, and a gt table report
View pointblank_demo.R
library(pointblank)
library(log4r)
library(blastula)
# Create a connection to the game analytics data
# This is the `intendo` database
con <-
DBI::dbConnect(
drv = RMariaDB::MariaDB(),
dbname = Sys.getenv("DBNAME"),
View gist:b381d687696aaa71a4548e92debe217d
modify_rows <- function(df, rows, func) {
df[rows,] <- func(df[rows,])
df
}
modify_rows(tbl, tbl$locname == "column_group", function(tbl) {
tbl <- tbl %>% mutate(colname
})
@rich-iannone
rich-iannone / yr_daily_rainfall_2015.R
Last active Feb 28, 2016
Using several R packages (stationaRy, DiagrammeR, DiagrammeRsvg, magrittr, and dplyr), you can create a time-series plot of weather-related things. Here, I plotted daily rainfall during 2015.
View yr_daily_rainfall_2015.R
# Load in several packages
devtools::install_github("rich-iannone/DiagrammeR")
library(DiagrammeR)
library(DiagrammeRsvg)
library(magrittr)
library(stationaRy)
library(dplyr)
# Get the daily rainfall values (in mm) during 2015 at
# the Vancouver Internation Airport (YVR)
@rich-iannone
rich-iannone / sp500_diagrammer.R
Last active Feb 28, 2016
Time series graph of S&P 500 data going back to 1950. Uses DiagrammeR for R.
View sp500_diagrammer.R
devtools::install_github("rich-iannone/DiagrammeR")
library(DiagrammeR)
library(DiagrammeRsvg)
library(magrittr)
# Read in the data
sp500 <- read.csv(system.file("examples/sp500.csv",
package = "DiagrammeR"),
stringsAsFactors = FALSE)