Skip to content

Instantly share code, notes, and snippets.

plot.nnet<-function(mod.in,nid=T,all.out=T,all.in=T,wts.only=F,rel.rsc=5,circle.cex=5,node.labs=T,
line.stag=NULL,cex.val=1,alpha.val=1,circle.col='lightgrey',pos.col='black',neg.col='grey',...){
require(scales)
#gets weights for neural network, output is list
#if rescaled argument is true, weights are returned but rescaled based on abs value
nnet.vals<-function(mod.in,nid,rel.rsc){
library(scales)
@sjewo
sjewo / wms_proto.R
Created October 28, 2013 11:12 — forked from jlehtoma/wms_proto.R
# Author: Joona Lehtomäki <joona.lehtomaki@gmail.com>
# Updated: 13.11.2011
# Version: 0.0.1
if (!require("rgdal")) {
install.packages("rgdal")
}
if (!require("raster")) {
install.packages("raster")
/*
* NAME
*
* statistics-distributions.js - JavaScript library for calculating
* critical values and upper probabilities of common statistical
* distributions
*
* SYNOPSIS
*
*
@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)
@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 / 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)
# 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) {