Skip to content

Instantly share code, notes, and snippets.

View pvictor's full-sized avatar

Victor Perrier pvictor

View GitHub Profile
@cderv
cderv / knitr_child_ex1.Rmd
Last active January 27, 2019 16:03
Examples for Rmarkdown cookbook
---
title: "Programmatically create a document"
date: "`r Sys.Date()`"
output:
pagedown::html_paged:
toc: true
# change to true for a self-contained document, but it'll be a litte slower for Pandoc to render
self_contained: false
---
@slowkow
slowkow / plot_repel.R
Last active May 2, 2018 21:07
Repel text labels away from each other in a ggplot2 figure.
library(ggplot2)
library(FField)
# You'll have to play with repulsion, cex.x, and cex.y to get satisfactory results.
plot_text <- function(x, y, label, repulsion = 1, cex.x = 110, cex.y = 40) {
dat <- data.frame(xpos = x, ypos = y, label = label)
dat$label <- as.character(dat$label)
# Use the FField package to repel the text labels away from each other.
dat <- cbind(