{{ message }}

Instantly share code, notes, and snippets.

# Brandon bfoste01

Created Apr 20, 2018
Marginal histogram scatterplot
View fancyaxis.R
 ## fancyaxis: Draw axis which shows minimum, maximum, quartiles ## and mean ## ## Copyright (C) 2005 Steven J. Murdoch ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ##
Last active Apr 20, 2018
Range-frame plot in ggplot2 with qfplot
View qfplot.r
 # credit: https://raw.githubusercontent.com/bearloga/Quartile-frame-Scatterplot/master/qfplot.R library(ggplot2) # by Hadley Wickham library(grid) # Required for the special axes. qfplot <- function(x,y,...) { # We use margins for a cleaner graph. # They are calculated as 5% of the range. # Feel free to play around with these (10% works well too). y.margin <- 0.05 * (max(y)-min(y))
Created Jun 9, 2015
View bayes_fisher.r
 #addmargins(table) # for freq table reference and input bayes.fisher <- function(y1, n1, y2, n2) { # SIMULATION I = 10000 # simulations theta1 = rbeta(I, y1+1, (n1-y1)+1) theta2 = rbeta(I, y2+1, (n2-y2)+1) diff = theta1-theta2 # simulated diffs # OUTPUT quantiles = quantile(diff,c(0.005,0.025,0.5,0.975,0.995))
Created Jun 1, 2015
For creating value labels
View value_label.r
 rise\$PEduc <- factor(rise\$PEduc, levels = c(1:7), labels = c("No Formal Schooling", "Some Elementary School", "Completed Elementary School", "Some Middle and High School", "Competed High School Diploma or GED", "Some College", "Completed 4-Year Degree or Higher"))
Last active Aug 29, 2015
power analysis for SEM models
View monte-carlo.r
 #----------------Structural Model--------------# # Monte Carlo (MC) Study with a Simple CFA w/no missing data # The idea with this MC study is to specify a theoretical model, # by this I mean you input the hypothesized parameter estimates # or estimates from a model you have already run. # The Monte Carlo aspect means to examine the variability # in the parameter estimates and fit statistics. # MC studies are an important element to establish # power in a study. #-----MC Study of Uncertainty in Parameter Estimates-----#
Created Jul 24, 2014
View plyr.r
 #Fun stuff with plyr #------------------- #plyr .data, .variables to split on and .fun function applied #understand the naming conventions of plyr with the first 2 letters #e.g., ddply dd= split dataframe apply function out dataframe #e.g., dlply dl = split dataframe apply function out list #d = dataframe #l = list #a = array #-------------------
Created Jul 24, 2014
View renaming.r
 #get variable names for mtcars dataset in rbase colnames(mtcars) #if yow want to recode variables the lazy way fix(mtcars) #downside is that it isn't hard coded, and therefore not reproducible #use the reshape package library(reshape) test <- rename(mtcars, c(disp="renamedisp")) #reproducible
Last active Aug 29, 2015
Insert Greek Symbols as Column Names in xtable outputs
View greeksanitize.r
 #create artifical data to emulate SEM model fit statistics chiSq <- 1600 df <- 780 p <- 0.95 CFI <- 0.95 TLI <- 0.95 RMSEA <- 0.04 LOWRMSEA <- 0.03 HIGHRMSEA <- 0.04
Created Apr 28, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
 // Use Gists to store code you would like to remember later on console.log(window); // log the "window" object to the console