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
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
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
<!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
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
# 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
\documentclass[12pt]{article} | |
\usepackage{sparklines} % makes inline curves | |
\begin{document} | |
Ten-year modelled CVD risk was 27.3 (SD 13.9, histogram | |
\begin{sparkline}{4} % start first sparkline | |
\sparkspike .083 .69 % first is x spacing, second is height | |
\sparkspike .25 .97 |
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(ggmap) | |
getLineColor <- function(val) { | |
#pal <- colorRampPalette(c("#333333", "#ffffff", "#b5310c")) | |
pal <- colorRampPalette(c("#ffffff", "red")) | |
colors <- pal(80) | |
val.log <- log(val) | |
if (val > 50) { | |
col <- colors[80] |
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
setwd("Directoy where the data is saved") | |
library(plyr) # used to read in csvs | |
library(psych) # has the describe function | |
################ | |
# import data # | |
################ | |
# Data is in monthly CSV's, so loop over them pulling in data |
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
theme_bare <- theme(axis.line = element_blank(), | |
axis.text.x = element_blank(), | |
axis.text.y = element_blank(), | |
axis.ticks = element_blank(), | |
axis.title.x = element_blank(), | |
axis.title.y = element_blank(), | |
legend.position = "none") | |
cambridge <- get_map(location="Cambridge, UK", zoom=13, color="bw", source="osm") |