Skip to content

Instantly share code, notes, and snippets.

View potterzot's full-sized avatar

Nicholas Potter potterzot

View GitHub Profile
@gmbecker
gmbecker / broken.Rmd
Last active September 26, 2018 04:25
DebuggingInRmd
We set up knitr so it doesn't catch errors, then set
`options(error=recover)` to set up R's debug-on-error machinery.
We have to do one additional thing, before the options call though:
trace the recover function with`sink(NULL)` to turn off the output
capturing so the R console is useful when the debugging framework
dumps us back into it. This has to happen before the options call
because that call grabs the `recover` object and stores it somewhere
so setting a trace on recover after the call won't affect the cached
version that gets called upon an error.
@karawoo
karawoo / server.R
Created July 31, 2015 21:34
Toggling user-selected layers with ggplot2 in a Shiny app
library("shiny")
library("ggplot2")
shinyServer(function(input, output) {
output$myplot <- renderPlot({
## Create a boxplot with optional jittering
p <- ggplot(iris, aes(x = Species, y = Petal.Length)) +
@hrbrmstr
hrbrmstr / ghelp.R
Last active August 29, 2015 14:23
github search in rstudio viewer pane - source it and try it with ghelp("vapply")
ghelp <- function(topic, in_cran=TRUE) {
require(htmltools) # for getting HTML to the viewer
require(rvest) # for scraping & munging HTML
# github search URL base
base_ext_url <- "https://github.com/search?utf8=%%E2%%9C%%93&q=%s+extension%%3AR"
ext_url <- sprintf(base_ext_url, topic)
# if searching with user:cran (the default) add that to the URL