Skip to content

Instantly share code, notes, and snippets.

View stefanedwards's full-sized avatar

Stefan McKinnon Edwards stefanedwards

View GitHub Profile
@stefanedwards
stefanedwards / app.R
Last active November 30, 2018 14:08
Shiny: linking outputBinding with output (issue with multiple outputs)
library(shiny)
redOutput <- function(inputId) {
tagList(
singleton(tags$head(tags$script(src="red.js"))),
div(id=inputId, class='redOutput')
)
}
@stefanedwards
stefanedwards / shiny_gtable_interactive_app.R
Created July 4, 2018 13:52
Demonstrates how to have interactive plots with renderPlot(click, hover, doubleclick) on custom gtable objects.
#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
library(shiny)
@stefanedwards
stefanedwards / copy_wmf_to_clipboard.R
Created July 3, 2018 12:29
Copy sparklines and inline figures from R to clipboard for pasting in Word
library(ggplot2)
library(grid)
library(gridExtra)
theme_mini <- theme_minimal(9)
win.metafile("", width=1, height=0.4, pointsize=9) ## copy to clipboard ! :D
print(p)
dev.off()
@stefanedwards
stefanedwards / fetch_pictures_to_dropbox.py
Created August 4, 2017 15:46
Copies photos from a folder, such as the DCIM folder of a digital camera, to a Dropbox folder, renaming the files according to their creation date in the process.
#!/usr/bin/python2.7
#############################
## Author: Stefan McKinnon Edwards <sme@iysik.com>
## Date: May 2013
## Revision: 1
## Description:
## Copies photos from a folder, such as the DCIM folder of a digital
## camera, to a Dropbox folder, renaming the files according to their
## creation date in the process.
#############################
@stefanedwards
stefanedwards / coord_closed_cart.R
Last active July 4, 2018 13:19
coord_cart wrapper that stops axes from protruding beyond the outer ticks. For ggplot 2.2.1.
warning('This coord_closed_cart.R script is deprecated. See R package lemon for updated function!')
#' Cartesian coordinates with closed range on axis-line.
#'
#' Use `theme(axis.line)` to set the axis-lines' style, as usual.
#' It might be necessary to set `theme(panel.border=element_blank())` to disable
#' the border that is drawn on top of the axis-lines.
#'
#' @param xlim,ylim Limits for the x and y axes.
#' @param expand If \code{TRUE}, the default, adds a small expansion factor to
@stefanedwards
stefanedwards / qsub1.py
Last active November 18, 2019 05:12
Python module for scripts running on a computation cluster with qsub. This module allows the script to request information such as job id, running time, remaining running time etc.
######
# author: Stefan McKinnon Edwards <stefan.hoj-edwards@agrsci.dk>
# id: $Id: qsub1.py 25 2013-04-12 11:06:47Z sme $
# qsub-module;
# communicates with cluster-queueing system to retrieve information
# about the current job.
# The qsub commands do no exist on the nodes, so to retrieve the necessary information,
# we ssh the host and request the information from `qstat`.
#
# To use this module from a script running on a computation cluster,