Skip to content

Instantly share code, notes, and snippets.

@skranz
skranz / s_dplyr
Created March 21, 2014 07:48
Wrappers to dplyr's data modification functions like arrange, select,... that work with string arguments.
# Helper functions that allow string arguments for dplyr's data modification functions like arrange, select etc.
# Author: Sebastian Kranz
# Examples are below
#' Modified version of dplyr's filter that uses string arguments
#' @export
s_filter = function(.data, ...) {
eval.string.dplyr(.data,"filter", ...)
}
@miku
miku / shellout.py
Last active June 25, 2017 16:14
shellout
def shellout(template, **kwargs):
"""
Takes a shell command template and executes it. The template must use
the new (2.6+) format mini language. `kwargs` must contain any defined
placeholder, only `output` is optional.
Raises RuntimeError on nonzero exit codes.
Simple template:
wc -l < {input} > {output}
@ramnathv
ramnathv / README.md
Last active December 26, 2015 12:59
Publish Slidify Decks as Gists

Slidify now allows you to publish your slide decks as gists. You will need the dev version of slidify to use this feature.

require(devtools)
install_github(c('slidify', 'slidifyLibraries'), 'ramnathv', ref = 'dev')

Let us first create a directory for our slide deck and open an index.Rmd file to author our presentation.

@hadley
hadley / .gitignore
Last active February 25, 2024 02:10
Benchmark different ways of reading a file
.Rproj.user
.Rhistory
.RData
*.Rproj
*.html
@baptiste
baptiste / knit
Last active December 20, 2015 19:39
Minimal example of a Rmd file that can be processed to produce both pdf and html output through pandoc, using two different file formats for the figures.
#!/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")
@Stiivi
Stiivi / customers_who_ordered-sql.py
Last active March 17, 2017 15:41
Another simple Bubbles example: Use two data sources: customers and orders CSV files (exports from Volusion platform). Get list of customers (name, email address) who made orders in certain range of years. There are two versions of the same process: one involves loading the data into a SQL table and performing the operations using SQL, the other…
from bubbles import Pipeline, open_store
stores = {
"source": open_store("csv", "data/source", encoding="utf16", infer_fields=True),
"target": open_store("sql", "sqlite:///data.sqlite")
}
p = Pipeline(stores=stores)
# Load customers into a SQL table
@trestletech
trestletech / README.md
Last active October 3, 2018 10:16
Shiny Example #3 for Bioconductor.

Bioconductor Shiny Example #3

Simple app showing the relationship between a gene's expression and survival.

This is an example Shiny app featuring some basic analysis of Ovarian Cancer gene expression data collected on the Affymetrix U133A platform. We filter the available genes and samples down to a much smaller matrix to make reproducibility simpler for a broader audience. The R code involved in sampling the data is available in this Gist as an R-Markdown file, and the sampled data are available in this Gist as Rds files.

To run the application, install shiny (install.packages("shiny")) then run the following command:

library(shiny)

@hadley
hadley / html.r
Last active December 18, 2015 03:58
# We first start by creating a way of escaping the characters that have special
# meaning for html, while making sure we don't end up double-escaping at any
# point. The easiest way to do this is to create an S3 class that allows us to
# distinguish between regular text (that needs escaping) and html (that
# doesn't).
#
# We then write an escape method that leaves html unchanged and escapes the
# special characters (&, <, >) in ordinary text. We also add a method for lists
# for convenience
@reinholdsson
reinholdsson / readme.md
Last active February 12, 2018 08:28
Programming Links
@wch
wch / app.r
Last active February 2, 2025 16:41
Shiny example app with dynamic number of plots
max_plots <- 5
ui <- fluidPage(
headerPanel("Dynamic number of plots"),
sidebarPanel(
sliderInput("n", "Number of plots", value=1, min=1, max=5)
),