Skip to content

Instantly share code, notes, and snippets.

View rmaia's full-sized avatar

Rafael Maia rmaia

View GitHub Profile
@rmaia
rmaia / label_specs.R
Created April 8, 2013 12:28
Adding the sample name to the end of the plotted spectra
data(sicalis)
# plot the desired spectra, leaving room horizontally to add labels
plot(sicalis, select=2:4, xlim=c(300,800))
# find the y position to add the labels right where they finish (wavelength=700)
# using nrow to select the last row (for the last wavelength value)
# subset the last wavelength value (column 1)
@rmaia
rmaia / ggplot_chulls.R
Last active November 29, 2023 07:54
Plot convex hulls according to a factor
require(ggplot2)
require(plyr)
# make toy data
set.seed(1)
dataf <- data.frame(
x = rnorm(100),
y = c(rnorm(50,-1), rnorm(50,1)),
cat = rep(c("A","B"), each=50)
)
@rmaia
rmaia / regplots.R
Created October 28, 2012 23:40
example regression plots with pretty CI shades
require(RColorBrewer)
# RColorBrewer provides the palettes developped by Cynthia Brewer, you can check them
# out at http://colorbrewer2.org/ .
# make some mock data with interaction
x1 <- factor(rep(c('a','b','c'),each=33))
x2 <- rnorm(99,10,2)