Skip to content

Instantly share code, notes, and snippets.

@benmarwick
benmarwick / SP_13_ARCHY_299_Lithics.R
Last active December 17, 2015 23:59
ARCHY 299/499 lithics lab: snippets of R code for basic exploration of our lithic data
# R script for plotting of basic lithic data from Gua Mo'o hono, Sulawesi
#### get data
# this block will connect to the internet to access our google sheet
# then download it directly into a dataframe ready to work on
# If this is the first time, a little preparation is necessary:
# In google sheet: File -> Publish to web -> publish all sheets;
# Get link to published data -> CSV, all sheets, copy-paste link here...
# make a list of the links to all our sheets...
@benmarwick
benmarwick / DFR-compare-files-citations.R
Last active December 18, 2015 06:39
Comparing the number of CSV files and the number of rows and unique IDs in the citations.CSV in DFR archives.
dfr <- c("2013.6.4.usytW8LZ",
"2013.1.1.E84E4jrp",
"2012.12.18.98btEyuG",
"2013.4.18.N45CdU3m",
"2013.4.20.FxFmBVYd",
"2013.4.29.jWU8ZEvg",
"2013.5.8.g6VTxDs5",
"2013.5.15.JkRSEQce")
# allocate list to hold results of loop...
@benmarwick
benmarwick / SP13_ARCHY_499_Geoarch.R
Last active December 18, 2015 08:19
ARCHY 499 SP13 R snippet for plotting basic geoarchaeological data from our google data sheet
############################################################
# Analysis of camsizer data on sediment samples
#
# clear the workspace
rm(list = ls())
# See the bottom to import data if you're coming back
# after having done all this previously, if this is the first
# run, carry on from here!
#
# Tell R where to look for the .xls data files, change this
read.tps = function(data) {
# Reads the .tps file format produced by TPSDIG
# (http://life.bio.sunysb.edu/morph/ into a single data frame
# USAGE: R> read.tps("filename.tps")
a = readLines(data) # so we can do some searching and indexing
LM = grep("LM", a) # find the line numbers for LM
ID.ind = grep("ID", a) # find the line numbers for ID
# and the ID values, SCALE values, and image names
ID = gsub("(ID=)(.*)", "\\2", grep("ID", a, value=T))
SCALE = gsub("(SCALE=)(.*)", "\\2", grep("SCALE", a, value=T))
@benmarwick
benmarwick / 3d-geom-morph.R
Created June 17, 2013 19:18
Basic operations with 3D models and geometric morphometric analysis in R (GPA, PCA, clustering, visualization)
## 3D model geometric morphometry
# start with NextEngine 3D scanner, acquire model and save in PLY format
# open PLY file in IDAV's free Landmark software and place landmarks
# export landmark point co-ords as a PTS file, then continue here:
## read in pst files of landmark co-ord that were made by Landmark (http://www.idav.ucdavis.edu/research/EvoMorph)
# placing landmarks can be done in R with 'shapes' or 'geomorph', but is easier with Landmark
# get file names
@benmarwick
benmarwick / citation-analysis-sketch.R
Last active February 1, 2025 15:00
sketch of citation analysis
# sources:
# http://www.jgoodwin.net/?p=1223
# http://orgtheory.wordpress.com/2012/05/16/the-fragile-network-of-econ-soc-readings/
# http://nealcaren.web.unc.edu/a-sociology-citation-network/
# http://kieranhealy.org/blog/archives/2014/11/15/top-ten-by-decade/
# http://www.jgoodwin.net/lit-cites.png
###########################################################################
# This first section scrapes content from the Web of Science webpage. It takes
@benmarwick
benmarwick / getting-julia
Created June 21, 2013 22:57
install and build Julia in ubuntu
# In a terminal... make sure I get the master branch
git clone -b master git://github.com/JuliaLang/julia.git
# needed these on EC2
sudo apt-get update
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install gfortran
sudo apt-get install make
@benmarwick
benmarwick / R_markdown_to_PDF.md
Last active December 18, 2015 20:59
Markdown chunk for quick and easy R markdown to PDF
# Load packages
setwd(wd) # assumes wd has been set earlier in the doc
require(knitr)
require(markdown)
 
# process .md and .pdf files (including smart punctuation and grey background of code blocks)
filen <- "names" # name of this markdown file without suffix
knit(paste0(filen,".md"))
system(paste0("pandoc -s ", paste0(filen,"-out.md"), " -t latex -o ", paste0(filen,".pdf"), " --highlight-style=tango -S"))
@benmarwick
benmarwick / Off-Our-Backs.rmd
Last active December 19, 2015 03:28
Quick and rough exploration of the JSTOR archive of 'Off Our Backs' using JSTORr. Document is in markdown and the last code block has code to make a PDF.
Quick look at 'Off Our Backs' with some of text mining functions in the R package [JSTORr][id1]
========================================================
Here I demonstrate some basic text mining of a selection of articles from 'Off Our Backs' that are held by JSTOR. I was motivated by [this blog post][id]. I tried with all articles that are one or more pages, but that resulted in some corrupt data (empty CSV files), so the data here are all articles with two or more pages. The methods here come from the R package [JSTORr][id1] and use the article as the basic unit of analysis. The motivation for this is that [JSTOR's DFR][id2] data are provided at the article level, and that does seem to provide interesting data at the scale of multiple thousands of articles. However, this is a lower level of resolution than corpus linguistics methods that use the word as the unit of analysis. So the results here might not compare well with corpus linguistics methods for a small sample of articles.
```{r, echo=TRUE, messag
Citation Network Analysis
========================================================
1. Go to http://apps.webofknowledge.com.offcampus.lib.washington.edu/
2. click the 'web of science' tab at the top
3. Do a search... refine search by journal... perhaps archaeolog* in 'publication title', hit 'search'
4. scroll to bottom of search results, where 'Output Records' section is
5. Select records -> 1-500 since 500 is max
6. Select content -> Full Record & Cited References