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(corrgram) | |
# Create correlagram of scatter against lines with conficence | |
# lines are loess smoothed curve | |
# eclipse is bivariate 68% concentration ellipse (68% of data inside!) | |
corrgram(Dataframe[,VECTORofCOLUMNSofINTEREST], order=FALSE, lower.panel=panel.pts, | |
upper.panel=panel.ellipse, text.panel=panel.txt, | |
diag.panel=panel.minmax, | |
main="Correlations between variables within the vector VECTORofCOLUMNSofINTEREST") |
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
#--The following was used to define the colours, but since it's a non-standard | |
# package, I've used the hexadecimal colour codes explicity below to avoid the | |
# need to install "RColorBrewer". See http://colorbrewer2.org/ for more info. | |
#require(RColorBrewer) | |
#colset <- brewer.pal(3, "Pastel2") | |
colset <- c("#B3E2CD", "#FDCDAC", "#CBD5E8") | |
path <- "http://www.sr.bham.ac.uk/~ajrs/R/datasets" | |
#--Data file as taken from XMM website, but with "#" added to comment lines |
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
# HOW TO BELOW | |
# http://www.sr.bham.ac.uk/~ajrs/R/r-tutorials.html#NEDplot | |
#--Read in data file: | |
url <- "http://www.sr.bham.ac.uk/~ajrs" | |
file <- "R/datasets/a85_extended_NEDsearch.txt" | |
A <- read.table(paste(url, file, sep="/"), sep="|", skip=20, header=TRUE) | |
close(url(paste(url, file, sep="/"))) # close connection after use | |
#--Specfify output graphics device: |
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
#Example Four Panel Contour Plot with One Legend | |
#Author: Carey R McGilliard | |
#September 2010 | |
#http://wiki.cbr.washington.edu/qerm/index.php/R/Contour_Plots | |
#This code uses a modified version of filled.contour called filled.contour3 (created by Carey McGilliard, Ian Taylor, and Bridget Ferris) | |
#to make an example figure of four contour plots sharing a legend (to the right). | |
#The example demonstrates how to use various color schemes for the contour plots and legend, but the user will want to | |
#pick one color scheme for all four plots such that the legend matches the plots. |
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
filled.contour3 <- | |
function (x = seq(0, 1, length.out = nrow(z)), | |
y = seq(0, 1, length.out = ncol(z)), z, xlim = range(x, finite = TRUE), | |
ylim = range(y, finite = TRUE), zlim = range(z, finite = TRUE), | |
levels = pretty(zlim, nlevels), nlevels = 20, color.palette = cm.colors, | |
col = color.palette(length(levels) - 1), plot.title, plot.axes, | |
key.title, key.axes, asp = NA, xaxs = "i", yaxs = "i", las = 1, | |
axes = TRUE, frame.plot = axes,mar, ...) | |
{ | |
# modification by Ian Taylor of the filled.contour function |
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
filled.legend <- | |
function (x = seq(0, 1, length.out = nrow(z)), y = seq(0, 1, | |
length.out = ncol(z)), z, xlim = range(x, finite = TRUE), | |
ylim = range(y, finite = TRUE), zlim = range(z, finite = TRUE), | |
levels = pretty(zlim, nlevels), nlevels = 20, color.palette = cm.colors, | |
col = color.palette(length(levels) - 1), plot.title, plot.axes, | |
key.title, key.axes, asp = NA, xaxs = "i", yaxs = "i", las = 1, | |
axes = TRUE, frame.plot = axes, ...) | |
{ | |
# modification of filled.contour by Carey McGilliard and Bridget Ferris |
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(vcd) | |
# create a matrix with two categorical variables. | |
VECTOR <- xtabs(~ Var1 + Var2, data = Dataframe) | |
# create mosiac | |
mosaic(VECTOR, gp = shading_max, split_vertical = TRUE) | |
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
# data | |
set.seed(1234) | |
bimodal <- c(rnorm(250, -2, 0.6), rnorm(250, 2, 0.6)) | |
uniform <- runif(500, -4, 4) | |
normal <- rnorm(500, 0, 1.5) | |
dataf <- data.frame (group = rep(c("bimodal","uniform", "normal"), each = 500), xv = c(bimodal, uniform, normal), cg = rep( c("A","B"), 750)) | |
require(beeswarm) | |
# hexagon |
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
# data | |
set.seed(4566) | |
data <- rnorm(100) | |
# Added to the plot: | |
par(mar=c(3.1, 3.1, 1.1, 2.1)) | |
hist(data,xlim=c(-4,4), col = "pink") | |
boxplot(data, horizontal=TRUE, outline=TRUE, ylim=c(-4,4), frame=F, col = "green1", add = TRUE) |
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
plot using ggplot2 | |
require(ggplot2) | |
#data | |
set.seed(1233) | |
data1 <- data.frame(pop =c(rep("A x B", 200), rep("A x C", 200), rep("B x C", 200) ) , var1 = c(rnorm(1000, 90,10), rnorm(1000, 50, 10), rnorm(1000, 20, 30))) | |
qplot( var1, data = data1, geom = "histogram" , group = pop, fill = pop, alpha=.3) + theme_bw( ) |
OlderNewer