This file contains hidden or 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
############################################################################## | |
## ## | |
## FORMATSNIPPETS.R ## | |
## ggplot format snippets ## | |
## ## | |
############################################################################## | |
#### LABELS #### | |
# Hide labels |
This file contains hidden or 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
# From http://cainarchaeology.weebly.com/r-package-for-seriation-via-ca.html | |
library(CAseriation) | |
data("perfect_seriation") | |
#loads the sample dataset | |
check.ca.plot(perfect_seriation,1,2) | |
#plot the Correspondence Analysis scatterplot of the first 2 dimensions in order #to inspect data structure (e.g., seeking for the horseshoe effect) | |
sort.table(perfect_seriation,1) |
This file contains hidden or 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
Tables Are Like Cockroaches | |
======================================================== | |
As much as I would like to completely replace all tables with beautiful, intuitive, and interactive charts, tables like cockroaches cannot be eliminated. Based on this very [interesting discussion on the Perceptual Edge forum](http://sfew.websitetoolbox.com/post/Old-or-oldest-data-table-5702966) with source [Exploring the Origins of Tables for Information Visualization](http://api.viglink.com/api/click?format=go&key=ccc2217bc2b75c4bdf5f7e57267f0464&loc=http%3A%2F%2Fsfew.websitetoolbox.com%2Fpost%2FOld-or-oldest-data-table-5702966&v=1&libid=1365001395530&out=http%3A%2F%2Fcsis.pace.edu%2F~marchese%2FPapers%2FIV11%2FMarchese_IV%252711.pdf&ref=http%3A%2F%2Fwww.google.com%2Furl%3Fsa%3Dt%26rct%3Dj%26q%3D%26esrc%3Ds%26frm%3D1%26source%3Dweb%26cd%3D2%26ved%3D0CDoQFjAB%26url%3Dhttp%253A%252F%252Fsfew.websitetoolbox.com%252Fpost%252FOld-or-oldest-data-table-5702966%26ei%3DpERcUcvxPImY9QTKi4GwCg%26usg%3DAFQjCNFppNIFLhtMVC3W9Xklbffh8lAm |
This file contains hidden or 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
#### prepare workspace | |
rm(list = ls(all.names = TRUE)) | |
gc() | |
#### get data into the R session | |
# set R's working directory | |
setwd("C:/Users/Marwick/Downloads/JSTOR") # change this to where you downloaded the data! | |
# Get zip file of CSVs from JSTOR and unzip | |
# this may take a few minutes... | |
unzip("2013.4.20.FxFmBVYd.zip") |
This file contains hidden or 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
package { "dkms": | |
ensure => latest, | |
} | |
package { "chromium-browser": | |
ensure => latest, | |
} | |
package { "emacs": | |
ensure => latest, |
This file contains hidden or 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
# test of storing a DTM on disk... | |
# reproducible data | |
library(tm) | |
data(crude) | |
dtm <- DocumentTermMatrix(crude) | |
library(filehash) | |
dbCreate("testDB") | |
db <- dbInit("testDB") |
This file contains hidden or 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
## See http://gettinggeneticsdone.blogspot.com/2013/06/customize-rprofile.html | |
## Load packages | |
library(BiocInstaller) | |
## Don't show those silly significanct stars | |
options(show.signif.stars=FALSE) | |
## Do you want to automatically convert strings to factor variables in a data.frame? | |
## WARNING!!! This makes your code less portable/reproducible. |
This file contains hidden or 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
#' An R function for creating simple D3 javascript directed network graphs. | |
#' | |
#' d3SimpleNetwork creates simple D3 javascript network graphs. | |
#' | |
#' @param data a data frame object with three columns. The first two are the names of the linked units. The third records an edge value. (Currently the third column doesn't affect the graph.) | |
#' @param Source character string naming the network source variable in the data frame. If \code{Source = NULL} then the first column of the data frame is treated as the source. | |
#' @param Target character string naming the network target variable in the data frame. If \code{Target = NULL} then the second column of the data frame is treated as the target. | |
#' @param height numeric height for the network graph's frame area. | |
#' @param width numeric width for the network graph's frame area. | |
#' @param file a character string of the file name to save the resulting graph. If a file name is given a standalone webpage is created, i.e. with a header and footer. If \code{file = NULL} then |
This file contains hidden or 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
```{r setup, echo=FALSE, results='hide'} | |
chunkref <- local({ | |
function(chunklabel) { | |
sprintf('[%s](#%s)', chunklabel, chunklabel ) | |
} | |
}) | |
secref <- local({ | |
function(seclabel) { | |
sprintf('[%s](#%s)', seclabel, seclabel ) |
This file contains hidden or 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
#check for and/or install dependencies | |
need<-c("RCurl","ggplot2","gridExtra","reshape2") | |
for(i in 1:length(need)){ | |
if(require(need[i], character.only = TRUE)==FALSE){ install.packages(need[i]);library(need[i], character.only = TRUE)} else { library(need[i],character.only = TRUE)} | |
} | |
if(require(pcaMethods)==FALSE){ | |
need<-c('Rcpp', 'rJava', | |
'Matrix', 'cluster', 'foreign', 'lattice', 'mgcv', 'survival') | |
for(i in 1:length(need)){ |