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
@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))
@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 / 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 / ggplot2 theme_minimal
Created May 4, 2012 13:58
ggplot2 theme_minimal
theme_minimal <- function (base_size = 12, base_family = "")
{
structure(list(axis.line = theme_blank(), axis.text.x = theme_text(family = base_family,
size = base_size * 0.8, lineheight = 0.9, vjust = 1),
axis.text.y = theme_text(family = base_family, size = base_size *
0.8, lineheight = 0.9, hjust = 1), axis.ticks = theme_segment(colour = "black",
size = 0.2), axis.title.x = theme_text(family = base_family,
size = base_size, vjust = 0), axis.title.y = theme_text(family = base_family,
size = base_size, angle = 90, vjust = 0.5), axis.ticks.length = unit(0.3,
"lines"), axis.ticks.margin = unit(0.5, "lines"), legend.background = theme_rect(colour = NA),
@low-decarie
low-decarie / anonym
Created May 5, 2012 03:48
anonymize a data.frame
#http://stackoverflow.com/questions/10454973/how-to-create-example-data-set-from-private-data-replacing-variable-names-and-l/10458688#10458688
anonym<-function(df){
if(length(df)>26){
LETTERS<-replicate(floor(length(df)/26),{LETTERS<-c(LETTERS, paste(LETTERS, LETTERS, sep=""))})
}
names(df)<-paste(LETTERS[1:length(df)])
level.id.df<-function(df){
level.id<-function(i){
We can't make this file beautiful and searchable because it's too large.
"","datum","peak","peak.group","variable","base.peak","smooth","value"
"1",1,FALSE,"1","A",FALSE,0,-7
"2",1,FALSE,"1","C",FALSE,0,-17
"3",1,FALSE,"1","G",FALSE,0,18
"4",1,FALSE,"1","T",FALSE,0,0
"5",2,FALSE,"1","A",FALSE,0,1
"6",2,FALSE,"1","C",FALSE,0,-4
"7",2,FALSE,"1","G",FALSE,0,9
"8",2,FALSE,"1","T",FALSE,0,-4
"9",3,FALSE,"1","A",FALSE,0,0
@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 / endnote.xml
Created October 4, 2012 02:00
EndNote XML example file
<?xml version="1.0" encoding="UTF-8" ?><xml><records><record><database name="EndNote Ecology.enl" path="/Users/LowDecarie/Dropbox/Meta presentation of stats/Data/EndNote Ecology.enl">EndNote Ecology.enl</database><source-app name="EndNote" version="15.0">EndNote</source-app><rec-number>13264</rec-number><foreign-keys><key app="EN" db-id="0xxzez5ectezp7e9zrnxp0dq5zrafepwxfe2">13264</key></foreign-keys><ref-type name="Journal Article">17</ref-type><contributors><authors><author><style face="normal" font="default" size="100%">Chapman, A. G.</style></author></authors></contributors><auth-address><style face="normal" font="default" size="100%">Cent States Forest Expt Stn, Columbus, OH USA</style></auth-address><titles><title><style face="normal" font="default" size="100%">An ecological basis for reforestation of submariginal lands in the Central Hardwood Region</style></title><secondary-title><style face="normal" font="default" size="100%">Ecology</style></secondary-title><alt-title><style face="normal" font="defa
@low-decarie
low-decarie / endnote_dataframe
Created October 5, 2012 20:16
example data frame for endnote import
structure(list(`Reference Type` = c("17", "17", "17"), Author = c("Whitfeld, T. J. S.Novotny, V.Miller, S. E.Hrcek, J.Klimes, P.Weiblen, G. D.",
"Peres-Neto, P. R.Leibold, M. A.Dray, S.", "Eaton, D. A. R.Fenster, C. B.Hereford, J.Huang, S. Q.Ree, R. H."
), Title = c("Predicting tropical insect herbivore abundance from host plant traits and phylogenyEcologyEcology",
"Assessing the effects of spatial contingency and environmental filtering on metacommunity phylogeneticsEcologyEcology",
"Floral diversity and community structure in Pedicularis (Orobanchaceae)EcologyEcology"
), `Secondary Title` = c("EcologyEcology", "EcologyEcology",
"EcologyEcology"), `Tertiary Title` = c("EcologyEcology", "EcologyEcology",
"EcologyEcology"), Pages = c("S211-S222", "S14-S30", "S182-S194"
), Volume = c("93", "93", "93"), Number = c("8", "8", "8"), Keywords = c("comparative methodsfood websherbivorylepidopteralowland rain forestnew guineaplant defenselowland rain-forestpapua-new-guineaspecies coexistencefunctional traitsDNA b
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