This file contains hidden or 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(lintr) | |
test_file <- tempfile(fileext = ".txt") | |
cat( | |
" | |
1 + 1 | |
switch('x', a = (1 + 1), b = 10, 12) # this is fine | |
x <- 20 | |
switch('x', b = 20, a = 12) # should find this one | |
print('foo') |
This file contains hidden or 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) | |
library(marquee) | |
library(rlang) | |
library(grid) | |
library(gtable) | |
# Constructor ------------------------------------------------------------- | |
#' Text guide | |
#' |
This file contains hidden or 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
rle_2d <- function(matrix) { | |
# If we have an empty matrix, we return 0-row data.frame | |
if (prod(dim(matrix)) < 1) { | |
ans <- data.frame( | |
col.start = integer(), | |
col.end = integer(), | |
row.start = integer(), | |
row.end = integer(), | |
value = as.vector(matrix) |
This file contains hidden or 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(epoxy) | |
library(ggplot2) | |
library(ggtext) | |
# Creating an epoxy theme element | |
element_epoxy <- function(...) { | |
el <- ggtext::element_markdown(...) | |
class(el) <- union("element_epoxy", class(el)) | |
el | |
} |
This file contains hidden or 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(grid) | |
library(scales) | |
library(textshaping) | |
label <- "Here be some text on a path" | |
# Setup some curve | |
t <- seq(10, 0, by = -0.05) | |
curve <- data.frame( |
This file contains hidden or 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 libraries | |
library(ggplot2) | |
library(grid) | |
library(rlang) | |
library(grImport2) | |
# Replace by intended SVG file | |
file <- "https://upload.wikimedia.org/wikipedia/commons/d/db/Brain_Drawing.svg" | |
download.file(file, tmp <- tempfile(fileext = ".svg")) |
This file contains hidden or 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) | |
accidental_art <- function(x, r = 1.9) { | |
x <- cor(x) | |
n <- dim(x)[1] | |
mask <- matrix(0, ncol(x), nrow(x)) | |
rad <- n/2 | |
xcen <- 0 | |
ycen <- 0 | |
This file contains hidden or 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(grid) | |
library(scales) | |
library(gtable) | |
library(rlang) | |
# Constructor ------------------------------------------------------------- | |
#' Combination matrix axis | |
#' | |
#' @inheritParams guide_axis |
This file contains hidden or 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
# Preface: | |
# This document has two function to rasterise ggplot2 layers. | |
# The functions are very similar in structure to those in thomas85's ggfx package (https://github.com/thomasp85/ggfx), | |
# The ggfx package is licenced under an MIT licence, so I think this should be OK. | |
library(ggplot2) | |
library(grid) | |
library(ragg) | |
library(png) |
This file contains hidden or 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) | |
library(tuneR) | |
midi <- tuneR::readMidi("https://www.8notes.com/school/midi/piano/beethoven_ode_to_joy.mid") | |
df <- tuneR::getMidiNotes(midi) | |
# Difference between first two notes | |
mult <- 960 |