Skip to content

Instantly share code, notes, and snippets.

View rich-iannone's full-sized avatar

Richard Iannone rich-iannone

View GitHub Profile
@rich-iannone
rich-iannone / pointblank_demo.R
Created January 30, 2020 07:51
A demonstration script that uses pointblank, logging, email notification, and a gt table report
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"),
@rich-iannone
rich-iannone / yr_daily_rainfall_2015.R
Last active February 28, 2016 09:12
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.
# 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 February 28, 2016 08:38
Time series graph of S&P 500 data going back to 1950. Uses DiagrammeR for 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)
@rich-iannone
rich-iannone / sf_salaries.R
Last active March 10, 2021 09:47
Plotting SF salaries using the DiagrammeR R package. Dataset is available from Kaggle Datasets.
library(DiagrammeR)
library(DiagrammeRsvg)
library(magrittr)
# The CSV file is located inside a zip file at:
# https://www.kaggle.com/kaggle/sf-salaries/downloads/
# sf-salaries-release-2015-12-21-03-21-32.zip
salaries <- read.csv("Salaries.csv",
stringsAsFactors = FALSE)
@rich-iannone
rich-iannone / iris_plot_DiagrammeR.R
Last active February 11, 2016 01:36
How to plot some Iris data with DiagrammeR and export as a PDF or PNG.
devtools::install_github("rich-iannone/DiagrammeR")
library(DiagrammeR)
library(DiagrammeRsvg)
library(magrittr)
# Create three groups (Setosa, Versicolor, and Virginica)
# of x,y datapoints for petal length (x) and petal width (y)
setosa <-
create_xy_pts(
series_label = "Setosa",
@rich-iannone
rich-iannone / diagrammer-left-to-right.R
Last active November 5, 2015 18:14
DiagrammeR Graphviz graph moving left to right (`rankdir`!)
devtools::install_github("rich-iannone/DiagrammeR")
library(DiagrammeR)
library(magrittr)
# Create a graph
graph <-
create_graph() %>%
set_global_graph_attr("graph", "rankdir", "LR") %>%
add_node("A") %>% add_node("B") %>% add_node("C") %>%
add_node("D") %>% add_node("E") %>% add_node("F") %>%
@rich-iannone
rich-iannone / world-cities-diagrammer.R
Created October 5, 2015 07:08
Demonstration code for plotting a graph of world cities along with country borders with the DiagrammeR R package.
# Installation
#install.packages("devtools")
devtools::install_github("rich-iannone/DiagrammeR")
library(DiagrammeR)
# Create a graph of border coordinates
country_graph <- country_graph()
# Read in a CSV with location and population data for cities all over the world
@rich-iannone
rich-iannone / diagrammer-us-cities.R
Last active September 9, 2023 23:55
Demonstration code for plotting a graph of US cities along with country borders with the DiagrammeR R package.
# Installation
#install.packages("devtools")
devtools::install_github("rich-iannone/DiagrammeR")
library(DiagrammeR)
# Create a graph of border coordinates for USA, Canada, and Mexico
country_graph <- country_graph(iso_a2 = c("US", "CA", "MX"))
# Read in a CSV with US city data
@rich-iannone
rich-iannone / diagrammer-fixed-nodes-visnetwork.R
Last active October 2, 2015 03:34
Fixed nodes (with specified positions) in DiagrammeR
# Installation
#install.packages("devtools")
devtools::install_github("rich-iannone/DiagrammeR")
library(DiagrammeR)
# Create and render an empty graph
empty_graph <- create_graph()
render_graph(empty_graph, output = "visNetwork")
@rich-iannone
rich-iannone / DiagrammeR_trigger_script.R
Last active September 20, 2023 06:22
DiagrammeR (https://github.com/rich-iannone/DiagrammeR)— Trigger a script from inside a graph series and modify that graph series. Uses the 'create_series' and 'trigger_script' functions.
# Install the latest version of DiagrammeR from GitHub
devtools::install_github("rich-iannone/DiagrammeR")
# Ensure that the package is loaded
library("DiagrammeR")
# So, here's a script that essentially takes an empty graph series, and
# creates a new graph on each new day it is triggered. It will create
# random nodes each time it's triggered and add those nodes to the graph
# belonging to the current day. Throughout the script, '_SELF_' refers