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
| --- | |
| title: " Embedded Shiny Apps" | |
| runtime: shiny | |
| output: | |
| html_document: | |
| theme: united | |
| --- | |
| ## Setup |
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
| > isIn <- function(x, y) { | |
| + sel <- match(x, y) | |
| + y[sel] | |
| + } | |
| > x <- sample(LETTERS, 5) | |
| > isIn(x, LETTERS) | |
| [1] "Q" "Z" "K" "V" "U" | |
| > | |
| > x | |
| [1] "Q" "Z" "K" "V" "U" |
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
| (defun insert-md-code-chunk () | |
| "Insert Rmd code chunk" | |
| (interactive) | |
| (insert "```\n\n```") | |
| (backward-char 4)) | |
| (defun insert-rmd-code-chunk () | |
| "Insert Rmd code chunk" | |
| (interactive) | |
| (insert "```{r}\n\n```") |
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
| ## l1 is a list with 20 numeric elements of length 1e4 each | |
| set.seed(123) | |
| l2 <- l1 <- replicate(20,rnorm(1e4),simplify=FALSE) | |
| length(l1) | |
| sapply(l1,length) | |
| ## l2 is the same list with names | |
| names(l2) <- paste0("X", 1:length(l2)) |
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
| ;; grep -h X-Key */*/cur/* | sed -e 's/X-Keywords: //; s/, /\n/g' | sort | uniq > xkeys.txt | |
| (setq mu4e-xkeys "~/Maildir/xkeys.txt") | |
| (defun read-lines (f) | |
| "Return a list of lines of a file at f." | |
| (with-temp-buffer | |
| (insert-file-contents f) | |
| (split-string (buffer-string) "\n" t))) |
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(base64enc) | |
| library(RJSONIO) | |
| library(httr) | |
| default_key <- function () { | |
| key <- Sys.getenv("POSTMARKAPP_API_KEY") | |
| if (key == "") { | |
| stop("Either provide key or set envvar POSTMARKAPP_API_KEY", call. = FALSE) | |
| } | |
| key |
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
| getDependencies <- function(p, | |
| rep = c("BioCsoft", "BioCann", "BioCexp", "BioCextra", "CRAN"), | |
| biocVersion = "2.12", | |
| depLevels = c("Depends", "Imports", "Suggests"), | |
| filter = TRUE) { | |
| rep <- match.arg(rep) | |
| if (rep == "CRAN") { | |
| rep <- getOption("repos")["CRAN"] | |
| } else { | |
| biocMirror <- getOption("BioC_mirror", "http://bioconductor.org") |
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
| ## http://gettinggeneticsdone.blogspot.co.uk/2012/09/deseq-vs-edger-comparison.html | |
| library(DESeq) | |
| library(edgeR) | |
| library(VennDiagram) | |
| # Read in data ------------------------------------------------------------ | |
| ## Use pasilla data | |
| datafile = system.file( "extdata/pasilla_gene_counts.tsv", package="pasilla" ) |
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(kernlab) | |
| > data(iris) | |
| > irismodel1 <- ksvm(Species ~ ., data = iris) | |
| Using automatic sigma estimation (sigest) for RBF or laplace kernel | |
| > irismodel2 <- ksvm(Species ~ ., data = iris) | |
| Using automatic sigma estimation (sigest) for RBF or laplace kernel | |
| > table(predict(irismodel1, iris[,-5]), predict(irismodel2, iris[,-5])) | |
| setosa versicolor virginica | |
| setosa 50 0 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
| scatterhist <- function(x, y, xlab="", ylab="", ...){ | |
| zones <- matrix(c(2,0,1,3), ncol=2, byrow=TRUE) | |
| layout(zones, widths=c(4/5,1/5), heights=c(1/5,4/5)) | |
| xhist <- hist(x, plot=FALSE) | |
| yhist <- hist(y, plot=FALSE) | |
| top <- max(c(xhist$counts, yhist$counts)) | |
| par(mar=c(3,3,1,1)) | |
| plot(x,y, ...) | |
| par(mar=c(0,3,1,1)) | |
| barplot(xhist$counts, axes=FALSE, ylim=c(0, top), space=0) |