Skip to content

Instantly share code, notes, and snippets.

View low-decarie's full-sized avatar

Etienne low-decarie

  • Canadian Space Agency
  • Montreal
View GitHub Profile
stat_smooth_func <- function(mapping = NULL, data = NULL,
geom = "smooth", position = "identity",
...,
method = "auto",
formula = y ~ x,
se = TRUE,
n = 80,
span = 0.75,
fullrange = FALSE,
level = 0.95,
######################################
## Function that organizes the data so that PGLMM can be fit
## Created by Matthew Helmus
##
## attempt at fixing the function for use with larger data sets
## diag is replaced with Matrix:::Diagonal
######################################
require(Matrix)
######################################
## Function calls a PGLMM for logistic regression
## Created by Matthew Helmus
######################################
PGLMM.fit<-function(dat=NULL,Y=NULL,X=NULL,VV=NULL,sp.init=0.5,maxit=25,exitcountermax=50) # [B,B0,s,S95int,LL,flag]=PGLMM_nosparse_funct(Y,X,VV,s)
{
if (!require(corpcor))
{
stop("The 'corpcor' package is required")
tell application "Microsoft PowerPoint"
activate
set theView to view of document window 1
repeat with slideNumber from 1 to count of slides of active presentation
go to slide theView number slideNumber
tell slide slideNumber of active presentation
@low-decarie
low-decarie / varEntryDialog.r
Created August 22, 2012 18:02 — forked from jbryer/varEntryDialog.r
Function to create a tcl/tk dialog box for a user to enter variable values.
#' Creates a dialog box using tcl/tk to get input from the user.
#'
#' This function will create a tcl/tk dialog box to get user input. It has been
#' written to be extensible so the R programmer can easily create a dialog with
#' any number of varaibles with custom labels and data conversion of the user
#' entered data. The function will return a list where the element names are
#' \code{vars} and the value is the user input. By default, all entry will be
#' converted using the \code{as.character} function. However, this can easily be
#' altered using the \code{fun} parameter. For example, if integers are required,
#' use \code{fun=c(as.integer, ...)}. It is also possible to write custom
@low-decarie
low-decarie / plotmatrix2.R
Created April 30, 2012 15:16 — forked from alaiacano/plotmatrix2.R
plotmatrix with aesthetics
plotmatrix2 <- function (data, mapping = aes())
{
grid <- expand.grid(x = 1:ncol(data), y = 1:ncol(data))
grid <- subset(grid, x != y)
all <- do.call("rbind", lapply(1:nrow(grid), function(i) {
xcol <- grid[i, "x"]
ycol <- grid[i, "y"]
data.frame(xvar = names(data)[ycol], yvar = names(data)[xcol],
x = data[, xcol], y = data[, ycol], data)
}))
@low-decarie
low-decarie / Sankey.R
Created April 23, 2012 18:39 — forked from aaronberdanier/Sankey.R
Program for creating sankey diagrams in R
SankeyR <- function(inputs, losses, unit, labels, format="plot"){
########################
# SankeyR version 1.01 (updated August 10, 2010)
# is a function for creating Sankey Diagrams in R.
# See http://www.sankey-diagrams.com for excellent examples of Sankey Diagrams.
#
# OPTIONS:
# 'inputs' is a vector of input values
# 'losses' is a vector of loss values
# 'unit' is a string of the unit
@low-decarie
low-decarie / readtps.R
Created March 21, 2012 12:18 — forked from mrdwab/readtps.R
read.tps function for R
read.tps = function(data) {
# Reads the .tps file format produced by TPSDIG
# (http://life.bio.sunysb.edu/morph/ into a single data frame
# USAGE: R> read.tps("filename.tps")
a = readLines(data) # so we can do some searching and indexing
LM = grep("LM", a) # find the line numbers for LM
ID.ind = grep("ID", a) # find the line numbers for ID
# and the ID values, SCALE values, and image names
ID = gsub("(ID=)(.*)", "\\2", grep("ID", a, value=T))
SCALE = gsub("(SCALE=)(.*)", "\\2", grep("SCALE", a, value=T))