Skip to content

Instantly share code, notes, and snippets.

# somewhat hackish solution to:
# https://twitter.com/EamonCaddigan/status/646759751242620928
# based mostly on copy/pasting from ggplot2 geom_violin source:
# https://github.com/hadley/ggplot2/blob/master/R/geom-violin.r
library(ggplot2)
library(dplyr)
"%||%" <- function(a, b) {
@sjewo
sjewo / InsertLatex2RtfEps.bas
Last active March 16, 2017 12:09
Replace Latex2rtf marker with actual images (Linux only, as the path is modified to remove the missing figure folder)
' Replace Latex2rtf marker with actual images in LibreOffice
' Linux only, as the path is modified to remove the missing figure folder
Sub InsertLatex2RtfEps
oText = ThisComponent.Text
RDescrip = ThisComponent.createReplaceDescriptor
RDescrip.searchRegularExpression = True
RDescrip.searchString = "\[###([^\]]*)###\]"
rngs = ThisComponent.findAll(RDescrip)
@sjewo
sjewo / cartodougenik.R
Last active August 29, 2016 23:30
R code for cartograms (see Dougenik et al. 1985)
library(tmap)
library(sp)
library(rgeos)
library(maptools)
# Cartogram
# algorithm from Dougenik, Chrisman, Niemeyer (1985): An Algorithm To Construct Continuous Area Cartograms. In: Professional Geographer, 37(1), 75-81.
cartogram <- function(shp, weight, itermax=15, maxSizeError=1.0001) {
@sjewo
sjewo / PKGBUILD
Created March 6, 2015 12:46
Archlinux PKGBUILD for python-pypdftk
pkgname=python-pypdftk
pkgver=0.3
pkgrel=1
pkgdesc="Python module to drive the awesome pdftk binary."
arch=('i686' 'x86_64')
url="https://github.com/revolunet/pypdftk"
license=('MT')
depends=('pdftk-bin')
makedepends=('python-setuptools')
source=("https://github.com//sjewo/pypdftk/archive/v${pkgver}.tar.gz")
@sjewo
sjewo / PKGBUILD
Created March 6, 2015 08:49
Archlinux PKGBUILD for slowmovideo-git
# Maintainer: ZKenJ <zkenjm@gmail.com>
# Contributor: Cilyan
# Contributor: Dan Serban
# Contributor: sjewo
pkgname=slowmovideo-git
pkgver=20150206
pkgrel=1
pkgdesc="Video slow motion effect via interpolation"
arch=('i686' 'x86_64')
@sjewo
sjewo / selectVariableRange.R
Created August 7, 2014 12:32
Select all data.frame columns between two variables
##
## Filename: selectVariableRange.R
## Creation Date: 07-08-2014
## Last Modified: Do 07 Aug 2014 14:21:37 CEST
##
## Description: New Operator to define an vector with
## index numbers of columns between two
## variable names.
##
@sjewo
sjewo / stata13.R
Last active August 29, 2015 14:04
Read Stata 13 files into R with rPython and pandas
# install.packages("rPython")
# requires pandas
stata13 <- function(dat,
convert.factors = TRUE){
require("rPython")
# make dat known to python
python.assign('dat',dat)
@sjewo
sjewo / package.R
Created February 21, 2014 09:33 — forked from jbryer/package.R
#' Simplified loading and installing of packages
#'
#' This is a wrapper to \code{\link{require}} and \code{\link{install.packages}}.
#' Specifically, this will first try to load the package(s) and if not found
#' it will install then load the packages. Additionally, if the
#' \code{update=TRUE} parameter is specified it will check the currently
#' installed package version with what is available on CRAN (or mirror) and
#' install the newer version.
#'
#' @param pkgs a character vector with the names of the packages to load.
@sjewo
sjewo / xlsxToR.r
Created February 19, 2014 18:27 — forked from schaunwheeler/xlsxToR.r
library(XML)
library(plyr)
library(pbapply)
xlsxToR <- function(file, keep_sheets = NULL, header = FALSE) {
temp_dir <- file.path(tempdir(), "xlsxToRtemp")
suppressWarnings(dir.create(temp_dir))
file.copy(file, temp_dir)
/*
* NAME
*
* statistics-distributions.js - JavaScript library for calculating
* critical values and upper probabilities of common statistical
* distributions
*
* SYNOPSIS
*
*