library(microbenchmark)
set.seed(1024) nr <- 1e4 nc <- 100
m <- matrix(runif(nr * nc), nrow = nr, dimnames = list(paste0("g", seq_len(nr)), paste0("s", seq_len(nc))))
| #!/bin/bash | |
| # Partially convert Rnw presentations to Rmd syntax | |
| # - [x]: Code chunks | |
| # - [x]: Section headers | |
| # - [x]: Slide headers | |
| # - [x]: Presenter notes | |
| # - [x]: Lists | |
| # - [ ]: Inlinde code (sort of, not really) |
| ```{r} | |
| library(microbenchmark) | |
| set.seed(1024) | |
| nr <- 1e4 | |
| nc <- 100 | |
| m <- matrix(runif(nr * nc), nrow = nr, | |
| dimnames = list(paste0("g", seq_len(nr)), | |
| paste0("s", seq_len(nc)))) |
library(microbenchmark)
set.seed(1024) nr <- 1e4 nc <- 100
m <- matrix(runif(nr * nc), nrow = nr, dimnames = list(paste0("g", seq_len(nr)), paste0("s", seq_len(nc))))
| ############################################################################## | |
| # Calendar Heatmap # | |
| # by # | |
| # Paul Bleicher # | |
| # an R version of a graphic from: # | |
| # http://stat-computing.org/dataexpo/2009/posters/wicklin-allison.pdf # | |
| # requires lattice, chron, grid packages # | |
| ############################################################################## | |
| ## calendarHeat: An R function to display time-series data as a calendar heatmap |
| # A few simple rules from Stephen Wolfram's A New Kind of Science | |
| apply_rule <- function(x, rule = "254") { | |
| stopifnot(length(x) == 3) | |
| stopifnot(all(x %in% c(0, 1))) | |
| rules <- list("254" = c(1, 1, 1, 1, 1, 1, 1, 0), | |
| "250" = c(1, 1, 1, 1, 1, 0, 1, 0), | |
| "90" = c(0, 1, 0, 1, 1, 0, 1, 0), | |
| "30" = c(0, 0, 0, 1, 1, 1, 1, 0)) |
| (* | |
| display-specific fullscreen behavior | |
| enable fullscreen for specific applications on MacBook and disable fullscreen | |
| when using a larger external display | |
| adapted from: | |
| * https://gist.github.com/dsummersl/4175461 | |
| * http://daringfireball.net/2006/12/display_size_applescript_the_lazy_way | |
| *) |
| #' Extract labels and values from phenoData characteristics columns | |
| #' | |
| #' @details | |
| #' characteristics_ch1.1 characteristics_ch1.2 age batch | |
| #' age:54 batch:1 --> 54 1 | |
| #' age:35 batch:2 35 2 | |
| parse_characteristics <- function(x, sep = ": ") { | |
| --- | |
| title: "test" | |
| output: | |
| html_document: | |
| keep_md: yes | |
| --- | |
| ```{r} | |
| library(qtl) | |
| library(qtlcharts) |
| # Identify clusters of contiguous factors within a dendrogram | |
| # Aaron Wolen | |
| # | |
| # See http://www.plosone.org/article/info%3Adoi%2F10.1371%2Fjournal.pone.0038422 | |
| # for an example situation in which this would be useful | |
| # | |
| # x: dendrogram | |
| # f: a named vector containing the factor that defines the grouping of leaves, | |
| # must be named using the same values that define x's leaf labels |
| # Extract and append multiple values embedded in rows | |
| # | |
| # data: data.frame | |
| # col: column name containing embedded values | |
| # sep: regular expression to split column by | |
| # | |
| # df <- data.frame(key = c("a", "a;b", "a;b;c"), val = 1:3) | |
| # unembed(df, "key", ";") | |
| unembed <- function(data, col, sep, ...) { |