Skip to content

Instantly share code, notes, and snippets.

View rjbgoudie's full-sized avatar

RJB Goudie rjbgoudie

View GitHub Profile
@rjbgoudie
rjbgoudie / .gitignore
Created April 13, 2011 07:49 — forked from rbochet/.gitignore
.gitignore file for Latex and R on Mac OS X
# Latex files
*.aux
*.glo
*.idx
*.log
*.toc
*.ist
*.acn
*.acr
@rjbgoudie
rjbgoudie / basic-discrete.R
Created May 13, 2011 09:58
structmcmc: basic operation, discrete data
# Basic operation of structmcmc. See https://github.com/rbtgde/structmcmc
# Setup data frame
x1 <- factor(c("a", "a", "g", "c", "c", "a", "g", "a", "a"))
x2 <- factor(c(2, 2, 4, 3, 1, 4, 4, 4, 1))
x3 <- factor(c(FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE))
x <- data.frame(x1 = x1, x2 = x2, x3 = x3)
# Draw samples from the posterior using MC^3.
set.seed(1234)
@rjbgoudie
rjbgoudie / Rakefile.rb
Created May 13, 2011 10:32
Rakefile for public packages
def document(package)
rload = 'load(".RData")'
rdoc = "document(\"#{package}\")"
rsave = 'save.image()'
system "Rscript -e '#{rload}; #{rdoc}; #{rsave}'"
end
def build(package)
system "R CMD build #{package}"
end
@rjbgoudie
rjbgoudie / basic.R
Created May 13, 2011 13:37
parental: basic operation
# A `bn` object is created by specifying the parents of each node.
x <- bn(c(2), c(), c(1, 2))
grplot(x)
# Adjacency matrices can be converted to a `bn` using `as.bn`.
adj <- matrix(c(0, 0, 1, 1, 0, 0, 0, 0, 0), 3, 3)
x <- as.bn(adj)
grplot(x)
# Properties of a `bn`
@rjbgoudie
rjbgoudie / basic-normal.R
Last active May 28, 2019 10:45
structmcmc: basic operation, normal data
# Basic operation of structmcmc. See https://github.com/rbtgde/structmcmc
# Setup data frame
x1 <- rnorm(20)
x2 <- rnorm(20)
x3 <- rnorm(20)
x <- matrix(c(x1, x2, x3), ncol = 3)
net <- bn(integer(0), 1, 2)
# Draw samples from the posterior using MC^3.
@rjbgoudie
rjbgoudie / .aREADME
Created September 3, 2012 12:17
For diffs of .odc Oberon BlackBox files (as used by OpenBUGS and WinBUGS) in git
1. Download and compile Gert van Valkenhoef's excellent odcread
https://github.com/gertvv/odcread
This require "iconv"
2. Add the lines below to you ~/.gitconfig
3. Add the lines below to the .gitattributes file in the git repository
@rjbgoudie
rjbgoudie / command.sh
Created September 3, 2012 17:07
Convert .odc to .txt in all git revisions
find . -name "*.odc" -exec sh -c '/Users/rjbg/Documents/Work/src/odcread/odcread {} > {}.txt; rm {}' \;
stat_bin_step <- function(mapping = NULL, data = NULL,
geom = "step", position = "stack",
...,
binwidth = NULL,
bins = NULL,
center = NULL,
boundary = NULL,
breaks = NULL,
closed = c("right", "left"),
pad = FALSE,