Skip to content

Instantly share code, notes, and snippets.

View halpo's full-sized avatar

Andrew Redd halpo

View GitHub Profile
@halpo
halpo / 000-instructions.md
Created June 19, 2012 16:40
harvestr R users conference presentation.

Building a beamer presentation with knitr.

Introduction

The documents included are the input for knitr. In addition you need to have the tool pandoc installed. I also use a custom beamer template to add the University of Utah \institute command to the template. It also changes the indentation some.

Steps

  1. knit document with
@halpo
halpo / margins.R
Created September 21, 2016 21:27
spread_each and margins functions which compliment dplyr and tidyr packages.
margins <-
function( grouped #< [grouped_df] A data frame with groups defined.
, ... #< passed to `FUN`
, FUN=dplyr::summarize #< Summary function
, all.name = getOption("margins::all.name", "(All)")
){
"Add margins to summarization"
g <- groups(grouped)
com <- lapply(seq(0, length(g)), combn, x=g, simplify=FALSE)
com <- Reduce(c, com)