Skip to content

Instantly share code, notes, and snippets.

View johnmyleswhite's full-sized avatar

John Myles White johnmyleswhite

View GitHub Profile
@dmbates
dmbates / gist:5303570
Last active December 15, 2015 18:28
Formula, ModelFrame and ModelMatrix types

Formula, ModelFrame and ModelMatrix types

In R, the functions for fitting statistical models based on a linear predictor usually allow for a formula/data specification of the model. The data part is a data.frame object in R. In Julia the corresponding type is a DataFrame as implemented in the DataFrames package.

A formula object in R is an expression whose top-level operator is a unary or binary tilde, ~. The interpretation of many operators, including +, *, ^, \ and : are overridden in the formula language. See the result of

?formula

in R for the details.

anonymous
anonymous / Chutes.jl
Created December 24, 2012 03:32
Graphs in Julia... some preliminary thoughts
module Chutes
abstract Graph
abstract DGraph <: Graph
abstract UGraph <: Graph
typealias LabelType Dict{Int,Any}
type DenseGraph <: Graph
mat :: Matrix{Uint8}
@kjhealy
kjhealy / st2binding
Created November 5, 2012 16:22
R and ST2's REPL. Keybinding Example
[
// Modified Sublime-REPL keybindings for an "R-friendly" set of shortcuts.
// Copy and paste this text into the Key Bindings - User (under Preferences menu).
// For more information, see http://tomschenkjr.net/2012/05/17/using-sublime-text-2-for-r/
// Executes a selection of text in REPL, latter only displays code and does not execute
{ "keys": ["super+shift+enter"], "command": "repl_transfer_current", "args": {"scope": "selection"}},
// I disabled this one
//{ "keys": ["super+shift+enter", "r"], "command": "repl_transfer_current", "args": {"scope": "selection", "action":"view_write"}},
@simonbyrne
simonbyrne / jbug.jl
Created October 15, 2012 19:48
A bugs-type sampler in julia
require("extras/distributions.jl")
require("slicesampler.jl")
import Distributions.*
macro buildslicesampler(model)
# pull apart the model into variables and distributions
variables = Dict{Symbol,Expr}()
unboundvars = Set{Symbol}()
for line in model.args
type DataFrame{N,D}
data::D
end
immutable Field{s}
end
Field(s::Symbol) = Field{s}()
function DataFrame(;kwds...)
@quinnj
quinnj / juliacon2015.jl
Last active August 29, 2015 14:23
Managing Data in Julia: Old Tricks, New Tricks Code
Pkg.clone("https://github.com/quinnj/Mmap.jl")
Pkg.clone("https://github.com/quinnj/CSV.jl")
Pkg.add("ODBC")
Pkg.checkout("SQLite","jq/remodel")
Pkg.add("SQLite")
Pkg.checkout("SQLite","jq/updates")
reload("Mmap")
reload("CSV")
@cscheid
cscheid / main.jl
Created September 10, 2014 22:51
bare-bones stress majorization in julia
# You should totally ignore this because it's the first piece of Julia I've ever written.
# 2-clause BSD, blah.
function make_cycle(n)
result = Dict{Int32, Array{Int32}}()
for i = 1:n
ii = i - 1
push!(result, i, [1 + ((i+n-2) % n), 1 + i % n])
end
result