This file contains 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(gtable) | |
library(ggplot2) | |
library(plyr) | |
set.seed(1) | |
d <- data.frame(x=rep(1:10, 5), | |
y=rnorm(50), | |
g = gl(5,10)) | |
# example plot |
This file contains 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
#!/usr/bin/Rscript | |
require(knitr) | |
lf <- commandArgs(trailingOnly = TRUE) | |
if(!length(lf)) | |
lf = list.files(pattern="\\.rmd") | |
for (f in lf) | |
try(knit(f)) | |
md = paste0(sub("\\.[[:alnum:]]*$", "", lf), ".md") |
This file contains 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
gtable_arrange <- function(..., grobs=list(), as.table=TRUE, | |
top = NULL, bottom = NULL, | |
left = NULL, right = NULL, draw=TRUE){ | |
require(gtable) | |
# alias | |
gtable_add_grobs <- gtable_add_grob | |
dots <- list(...) | |
params <- c("nrow", "ncol", "widths", "heights", | |
"respect", "just", "z") # TODO currently ignored |
This file contains 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
gtable_layout <- function(grobs, widths = NULL, heights = NULL, | |
m, ...){ | |
if(is.null(widths)) | |
widths <- unit(rep(1,ncol(m)), "null") | |
if(is.null(heights)) | |
heights <- unit(rep(1,nrow(m)), "null") | |
cells <- sort(unique(c(m))) |
This file contains 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
require(ggplot2) | |
require(grid) | |
element_grob.element_custom <- function(element, label="", colour="black") { | |
disect <- strsplit(label, "\\n")[[1]] | |
N <- length(disect) | |
fun <- function(ii, colour) | |
textGrob(disect[ii], y=unit(N, "lines") - unit(ii-1, "lines"), gp=gpar(col=colour)) |
This file contains 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
ask = function(msg){ | |
h <- paste(capture.output(help(msg)), collapse="") | |
print(h) | |
if(nchar(msg) < 20){ | |
m <- paste0(stringr::str_extract_all(h,"\\?")[[1]], collapse="") | |
Recall(m) | |
} | |
} | |
ask("???") |
This file contains 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
global_settings { assumed_gamma 1.2 } | |
#include "colors.inc" | |
#include "textures.inc" | |
#include "glass.inc" | |
#declare R = 3; | |
#declare Rs = 0.05; | |
#declare Rd = R - Rs; | |
#declare dist = 1.0; | |
////// |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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) | |
lollipopGrob <- function(x, y, size, turns=3){ | |
theta <- seq(0, turns*2*pi, length=120) | |
xx <- unit(x, "npc") + unit(size*theta/max(theta)*cos(theta+pi), "mm") | |
yy <- unit(y, "npc") + unit(size*theta/max(theta)*sin(theta+pi), "mm") | |
segmentsGrob(head(xx, -1), head(yy, -1), tail(xx, -1), tail(yy, -1), | |
gp=gpar(col=hcl(seq(0,360,length=12), 90, 70), lwd=5)) |
This file contains 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
#' symmetrise_scale | |
#' | |
#' @param p ggplot2 | |
#' @param axis axis | |
#' | |
#' @return plot with scales adjusted | |
#' @export | |
#' @examples | |
#' p1 <- qplot(mpg, wt, data=mtcars, colour=cyl) + facet_wrap(~carb, nrow=1, scales="free") |