Skip to content

Instantly share code, notes, and snippets.

View jwolfson's full-sized avatar

Julian A Wolfson jwolfson

View GitHub Profile
@jwolfson
jwolfson / latex-options.Rnw
Created February 21, 2019 17:26
Creating a custom LaTeX exam+solution document
---
---
title: "`r sprintf('Exam Questions%s', ifelse(params$solutions, ' and Solutions', ''))`"
author: ""
date: ""
output: pdf_document
params:
solutions: TRUE
---
@jwolfson
jwolfson / 7430-CorHeatmap.R
Last active September 13, 2016 04:17
[PUBH 7430] Correlation heatmap in ggplot
library(ggplot2)
library(reshape2)
CorHeatmap <- function(corr.mat) {
# Get lower triangle of the correlation matrix
get_lower_tri<-function(cormat){
cormat[upper.tri(cormat)] <- NA
return(cormat)
}
@jwolfson
jwolfson / carved-design.R
Created January 18, 2016 05:14
Carved case design using R
par(mar=c(0,0,0,0))
plot(x, dbeta(x,shape1=4, shape2=4),
type = "l",
ylim = c(0,4),
bty = "n",
xaxt = "n",
yaxt = "n",
xlab = "",
ylab = "",
@jwolfson
jwolfson / runSim.sh
Last active October 17, 2020 09:31
A Bash script for monitoring R simulations
#### Simulation running/monitoring script
####
#### Run this as: ./runSim.sh YOUR_R_SOURCE_FILE.R ANY_TEXT_FILE.txt
####
#### Lines to edit before running are indicated by '##### **'
RFILE="$1"
OUTFILE="$2"
nohup nice -10 R --vanilla --slave < $RFILE > $OUTFILE & ## Defaults to running at medium-low priority (-10). Can increase this to improve performance (maybe).
@jwolfson
jwolfson / readSQLite.R
Last active April 19, 2024 01:42
Reading an SQLite .db file into R
library(RSQLite)
filename <- "your_db_file.db"
sqlite.driver <- dbDriver("SQLite")
db <- dbConnect(sqlite.driver,
dbname = filename)
## Some operations
dbListTables(db)
mytable <- dbReadTable(db,"your_table_name")