This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git config --global core.excludesfile ~/.gitignore | |
$ echo .DS_Store >> ~/.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ExportPlot <- function(gplot, filename, width=2, height=1.5) { | |
# Export plot in PDF and EPS. | |
# Notice that A4: width=11.69, height=8.27 | |
ggsave(paste(filename, '.pdf', sep=""), gplot, width = width, height = height) | |
postscript(file = paste(filename, '.eps', sep=""), width = width, height = height) | |
print(gplot) | |
dev.off() | |
png(file = paste(filename, '_.png', sep=""), width = width * 100, height = height * 100) | |
print(gplot) | |
dev.off() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ipak function: install and load multiple R packages. | |
# check to see if packages are installed. Install them if they are not, then load them into the R session. | |
ipak <- function(pkg){ | |
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])] | |
if (length(new.pkg)) | |
install.packages(new.pkg, dependencies = TRUE) | |
sapply(pkg, require, character.only = TRUE) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## regular case | |
foo <- function(a, b, c) a + b - c ## does something | |
foo2 <- function(b, c) b + c ## also some function | |
foo(a=1, b=2, c=5) | |
foo2(b=2, c=5) ## repeating list of multiple arguments | |
## passing a list | |
arg.list <- list(b=2, c=5) | |
do.call(foo, c(list(a=1), arg.list)) | |
do.call(foo2, arg.list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Transform raster to data.table | |
#' | |
#' @param x Raster* object | |
#' @param row.names `NULL` or a character vector giving the row names for the data frame. Missing values are not allowed | |
#' @param optional logical. If `TRUE`, setting row names and converting column names (to syntactic names: see make.names) is optional | |
#' @param xy logical. If `TRUE`, also return the spatial coordinates | |
#' @param centroids logical. If TRUE return the centroids instead of all spatial coordinates (only relevant if xy=TRUE) | |
#' @param sepNA logical. If TRUE the parts of the spatial objects are separated by lines that are NA (only if xy=TRUE and, for polygons, if centroids=FALSE | |
#' @param ... Additional arguments (none) passed to `raster::as.data.frame` | |
#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scale_x_discrete(limits = rev(levels(the_factor))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create some sample data | |
CV_1 <- 0.2 | |
CV_2 <- 0.3 | |
Mean <- 65 | |
sigma_1 <- sqrt(log(1 + CV_1^2)) | |
mu_1 <- log(Mean) - sigma_1^2 / 2 | |
sigma_2 <- sqrt(log(1 + CV_2^2)) | |
mu_2 <- log(Mean) - sigma_2^2 / 2 | |
q <- c(0.25, 0.5, 0.75, 0.9, 0.95) | |
SummaryTable <- data.frame( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Author: postmodern | |
# Description: | |
# Rips a DVD to a H.264 MKV file, with chapters and tags. Ignores any | |
# bad blocks or sectors on the DVD. | |
# Dependencies: | |
# * gddrescue | |
# * handbrake-cli | |
# * mkvtoolnix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# A script to set up a new mac. Uses bash, homebrew, etc. | |
# Focused for ruby/rails development. Includes many utilities and apps: | |
# - homebrew, rvm, node | |
# - quicklook plugins, terminal fonts | |
# - browsers: chrome, firefox | |
# - dev: iterm2, sublime text, postgres, chrome devtools, etc. | |
# - team: slack, dropbox, google drive, skype, etc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example 1 | |
p <- 0.5 | |
q <- seq(0,100,1) | |
y <- p*q | |
plot(q,y,type='l',col='red',main='Linear relationship') | |
# Example 2 | |
y <- 450 + p*(q-10)^3 | |
plot(q,y,type='l',col='navy',main='Nonlinear relationship',lwd=3) |
OlderNewer