Skip to content

Instantly share code, notes, and snippets.

# get list of wikileaks files and directories
library(rvest)
wl <- read_html("https://file.wikileaks.org/file/")
# get file/directory names & clean a little
wllt <-
wl %>%
# Get text of URLS
html_nodes("a") %>%
html_text() %>%
##############################################################################
## ##
## FORMATSNIPPETS.R ##
## ggplot format snippets ##
## ##
##############################################################################
#### LABELS ####
# Hide labels
@benmarwick
benmarwick / convert_doc_to_txt.R
Created January 17, 2017 10:59
Convert Microsoft Word documents (.doc, MS Word 97) into plain text, using R and libreoffice
# Assuming we are in the directory with the docs
# get a list of the files
the_docs <- list.files(pattern = ".doc$")
# remove spaces from the file names
file.rename(the_docs, gsub(" ", "_", the_docs))
# get the file names again
the_docs <- list.files(pattern = ".doc$|docx$")
@benmarwick
benmarwick / most_common_stat_tests.r
Last active May 29, 2019 15:50
What are the most frequently used statistical tests?
---
title: "What are the most frequently used statistical tests?"
author: "Ben Marwick"
date: "March 31, 2016"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE,
warning = FALSE,
@benmarwick
benmarwick / potting_custom_geom_shapes.r
Last active April 27, 2021 22:05
Adjust the shape of each data point to a custom polygon using variables
#' Polygon vertices for plotting computed from an object's linear dimensions
#'
#' This function takes a data frame (one row per object) of object dimensions,
#' where each object is defined by five linear measurements, and computes coords
#' of polygon vertices at given x and y values (taken from the data frame)
#'
#' @param data data frame with at least seven numeric columns
#' @param x column for x position of polygon centers
@benmarwick
benmarwick / csv2txts.R
Last active February 9, 2021 15:06
Convert a single CSV file (one text per row) into separate text files. A function in R.
#' Making several text files from a single CSV file
#'
#' Convert a single CSV file (one text per row) into
#' separate text files. A function in R.
#'
#' To use this function for the first time run:
#' install.packages("devtools")
#' then thereafter you just need to load the function
#' fom github like so:
#' library(devtools) # windows users need Rtools installed, mac users need XCode installed
@adamjohnson
adamjohnson / skeleton_wide.css
Created February 21, 2012 16:15
1200px Media Query for the Skeleton Grid
/* 1200px Media Query for the Skeleton Grid - http://getskeleton.com
* Adapted from http://www.aliaspooryorik.com/blog/index.cfm/e/posts.details/post/responsive-css-grid-systems-345
* Added .alpha.omega combo classes. Hope to see that fixed in later versions of Skeleton: https://github.com/dhgamache/Skeleton/issues/68
*/
@media only screen and (min-width: 1200px) {
.container { width: 1200px;}
.container .column,
.container .columns { margin-left: 10px; margin-right: 10px; }