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
library(ggplot2) | |
library(gridExtra) | |
mtcars$cyl <- ordered(mtcars$cyl) | |
p <- ggplot(mtcars, aes(mpg, hp, colour = cyl)) + geom_point() | |
p1 <- p + theme(legend.position = "none") | |
p2 <- ggplot(mtcars, aes(x=mpg, group=cyl, colour=cyl)) | |
p2 <- p2 + stat_density(fill = NA, position="dodge") |
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 code to reproduce Shawn Graham's topic model | |
# of the DH2013 conference abstracts: | |
# http://electricarchaeology.ca/2013/08/09/topic-modeling-dh2013-with-paper-machines/ | |
# Best run with RStudio. If things get sluggish, | |
# press CTRL-L to clear the console | |
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
# This script is a workflow for analysing 2D artefact outlines from 3D | |
# scan objects captured by NextEngine and ScanStudio. Part of the process | |
# occurs in ScanStudio and GIMP and the quantative analysis of the outlines | |
# is done in R. In GIMP we process the images into B&W silhouettes ready for R. | |
# In R we do elliptical fourier analysis to summarise the image outlines | |
# then PCA and MANOVA to discriminate between shape variations | |
# and test for differences | |
########### Using GIMP to preparing ScanStudio images for input into R ########### | |
## Get screenshot from scanstudio into GIMP |
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
This gist is no longer updated, see this one the for the most current version: | |
https://gist.github.com/benmarwick/6260541 | |
# This script is a workflow for analysing 2D artefact outlines from 3D | |
# scan objects captured by NextEngine and ScanStudio. Part of the process | |
# occurs in ScanStudio and GIMP and the quantative analysis of the outlines | |
# is done in R. In GIMP we process the images into B&W silhouettes ready for R. | |
# In R we do elliptical fourier analysis to summarise the image outlines | |
# then PCA and MANOVA to discriminate between shape variations | |
# and test for differences |
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
# basic workflow for ANOVA | |
# some fake example data | |
x <- runif(100) # The measurement variable (100 random numbers) | |
y <- sample(rep(letters[1:5], each=20)) # The catagorical variable (five groups) | |
# make a data frame of the x and y vectors | |
df <- data.frame(measure = x, group = y) | |
# inspec the data frame to make sure it looks right | |
str(df) |
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
## get data from google sheet | |
# connect to google sheet | |
require(RCurl) # if you get an error message here that says something like 'there is no package called 'RCurl'' | |
# then you need to install the package by typing this into the console (and then hitting enter): install.packages("RCurl") | |
# wait for the package to download and install, then run line 3 again before proceeding. | |
options(RCurlOptions = list(capath = system.file("CurlSSL", "cacert.pem", package = "RCurl"), ssl.verifypeer = FALSE)) | |
# in google spreadsheet, go to file-> publish to web -> get link to publish to web -> get csv file | |
goog <- "https://docs.google.com/spreadsheet/pub?key=0As7CmPqGXTzldE5UV3FOZTRlYy10ZF9JOWcxYy1tSGc&single=true&gid=0&output=csv" | |
# assign data from google sheet to R object | |
data <- read.csv(textConnection(getURL(goog)), stringsAsFactors = FALSE) |
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
########### working with the Horiba LA-950 data ###################### | |
# First step is to convert ngb files to txt, since ngb is not a format | |
# that R can read. | |
# 1. Open the LA-950 for windows program (I have a copy of the software you can have) | |
# 2. Go to the 'File List View' in the left panel, select all | |
# the files and right-click on them and select 'delete', then | |
# choose 'delete from file view' (not delete from computer) |
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
Here's the code for the Denny Yard data: | |
## Working with remote sensing data from GEM Gradiometer | |
# First get data from machine onto a computer. Here we've got the | |
# data on a google sheet... | |
# get data from google drive... connect to google sheet | |
require(RCurl) # if you get an error message here that says something like 'there is no package called 'RCurl'' | |
# then you need to install the package by typing this into the console (and then hitting enter): install.packages("RCurl") |
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
############################################################################### | |
############ Interpolate age from depth using local fitting (aka loess) ####### | |
# Assuming that we have a data frame called 'dates' that has a numeric variable called 'Depth.m' | |
# which is depth in meters and another called 'cal.median' which is an age determination in kya... | |
span <- 0.45 # this has a big influence on the shape of the curve, experiment with it! | |
cal.date.lo <- loess(cal.median ~ Depth.m, dates, span = span) | |
cal.date.pr <- predict(cal.date.lo, data.frame(Depth.m = seq(0, 5, 0.01))) | |
plot(cal.date.pr) # inspect to seee that it looks right |
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
# This file comes from: | |
# http://www.isem.univ-montp2.fr/recherche/teams/developmental-biology-and-evolution/staff/claudejulien/?lang=en | |
# Errata for the book are also on that webpage | |
## All code here originally written by Julien CLAUDE to accommpany his book 'Morphometrics with R'. | |
# I've simply reproduced the code here to make it easier for me to find and source. | |
######functions developped in Claude J. (2008). Morphometrics with R. Springer. | |
######Refer to the book if you use them | |
####f1.1 |