Skip to content

Instantly share code, notes, and snippets.

View raffdoc's full-sized avatar

Rafik Margaryan raffdoc

View GitHub Profile
library(ggplot2)
library(dplyr)
library(tidyr)
library(stringr)
library(scales)
library(gridExtra)
library(grid)
# use the NPR story data file ---------------------------------------------
# and be kind to NPR's bandwidth budget
@somada141
somada141 / python_dicom_load_pydicom.md
Created March 2, 2015 10:30
Load DICOM data into a NumPy array with PyDICOM #python #dicom #medical #imagedata #pydicom #fileIO
@yihui
yihui / README.md
Last active March 15, 2017 18:35
A Shiny app based on annyang that responds to voice input
@randyzwitch
randyzwitch / rsitecatalyst-sankey-one-page.R
Created September 10, 2014 20:42
RSiteCatalyst Sankey Diagram - Single Page to Multiple Pages
library("RSiteCatalyst")
library("d3Network")
#### Authentication
SCAuth("key", "secret")
#### Get Pathing data: Single page, then ::anything:: pattern
pathpattern <- c("http://randyzwitch.com/big-data-hadoop-amazon-ec2-cloudera-part-1", "::anything::")
next_page <- QueuePathing("zwitchdev",
"2014-01-01",
library(MCMCpack)
## Coping with polls: the more recent, the better they are.
##http://en.wikipedia.org/wiki/Opinion_polling_for_the_Scottish_independence_referendum,_2014
polls = NULL
polls <- data.frame( rbind(
Survation = c(37, 50, 1010),
YouGov = c(35, 55, 1142),
TNSBMRB = c(32, 45, 1003),
IpsosMORI = c(40, 54, 1006),
require(ipeds)
require(ggplot2)
require(reshape2)
require(scales)
data(surveys)
View(surveys)
# Directory
ipedsHelp('HD', 2012)
library(plyr)
library(ggplot2)
library(ggmap)
libraries = read.csv("ontario_library_stats_2010.csv")
libraries$isFN = ifelse(libraries$Library.Service.Type == "First Nations Library",1,0)
# Here we create the 'proportionate' versions of all the variables
libraries[,143:265] = sapply(libraries[,20:142], function (x) x/libraries[,13])
names(libraries)[143:265] = paste(names(libraries)[20:142], "P",sep=".")
@blmoore
blmoore / plos_authInflation.R
Last active June 28, 2018 15:00
For blog post
options(PlosApiKey = "<insert your API key here!>")
#install_github("rplos", "ropensci")
library("rplos")
library("ggplot2")
require("dplyr")
# Convert author strings to counts
countAuths <- function(cell)
length(unlist(strsplit(cell, ";")))
@araastat
araastat / ggkm.R
Last active July 6, 2018 17:39
Plotting a Kaplan-Meier curve using ggplot. ggkmTable.R adds a table below the plot showing numbers at risk at different times.
#’ Create a Kaplan-Meier plot using ggplot2
#
#’ @param sfit a \code{\link[survival]{survfit}} object
#’ @param returns logical: if \code{TRUE}, return an ggplot object
#’ @param xlabs x-axis label
#’ @param ylabs y-axis label
#’ @param ystratalabs The strata labels. \code{Default = levels(summary(sfit)$strata)}
#’ @param ystrataname The legend name. Default = “Strata”
#’ @param timeby numeric: control the granularity along the time-axis
#’ @param main plot title