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
# ggplot2 base layer | |
g <- ggplot(table) | |
# Bubble plots - edit limits and seq based on your data | |
(g + geom_point(aes(x = XAxis, y = YAxis, size = Percent, colour = total),shape=16, alpha=0.80) + | |
scale_colour_gradient(limits = c(0, 1400), low="blue", high="red", breaks= seq(0, 1400, by = 200)) + | |
scale_x_continuous(breaks = 1:4, labels=c("Category1", "Category2", "Category3","Category4")) + | |
scale_y_continuous(trans = "reverse") + coord_fixed(ratio=0.2) | |
) |
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
parallelset <- function(..., freq, col="gray", border=0, layer, | |
alpha=0.5, gap.width=0.05) { | |
p <- data.frame(..., freq, col, border, alpha, stringsAsFactors=FALSE) | |
n <- nrow(p) | |
if(missing(layer)) { layer <- 1:n } | |
p$layer <- layer | |
np <- ncol(p) - 5 | |
d <- p[ , 1:np, drop=FALSE] | |
p <- p[ , -c(1:np), drop=FALSE] | |
p$freq <- with(p, freq/sum(freq)) |
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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
svg { | |
font: 10px sans-serif; | |
} | |
.axis path { | |
display: none; |
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
class BubbleChart | |
constructor: (data) -> | |
@data = data | |
@width = 940 | |
@height = 600 | |
# locations the nodes will move towards | |
# depending on which view is currently being | |
# used |
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("beanplot") | |
#To make it do the split (male/female in my plot), I set a variable up as "MainGrouping" then | |
# a space followed by BinaryGrouping encoded as a numeric value (i.e. 1 or 2). | |
beanplot(ContinuousVariable ~ MainGrouping_BinaryGrouping, data = DATA, what=c(1,1,1,0), log="", | |
ylab = "Continous variable label", side = "both", | |
border = NA, beanlinewd = 0.5, overallline = "median", | |
col = list( "brown2", "cadetblue3")) | |
legend("topright", fill = c("brown2", "cadetblue3"), c("Binary 1", "Binary 2")) |
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
getPckg <- function(pckg) install.packages(pckg, repos = "http://cran.r-project.org") | |
pckg = try(require(wordcloud)) | |
if(!pckg) { | |
cat("Installing 'wordcloud' from CRAN\n") | |
getPckg("wordcloud") | |
require("wordcloud") | |
} | |
pckg = try(require(tm)) | |
if(!pckg) { |
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( ) |
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
# 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
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) | |