Skip to content

Instantly share code, notes, and snippets.

View raffdoc's full-sized avatar

Rafik Margaryan raffdoc

View GitHub Profile
@mollietaylor
mollietaylor / map-new-legend.R
Created September 29, 2013 23:02
Custom Legend in R
library(OIdata)
library(RColorBrewer)
library(classInt)
# load state data from OIdata package:
data(state)
# set constants:
nclr <- 8 # number of bins
min <- 0 # theoretical minimum
@Ram-N
Ram-N / google-research.R
Last active June 11, 2019 00:54
Google Research Grant recipients.
rm(list=ls())
library(ggplot2)
df <- read.csv("~/RStats/data/ResearchGrants2013.csv", stringsAsFactors=F, strip.white=T)
df <- df[,-6] #get rid of the trailing blank
dim(df)
#quick check
unique(df$Research.Category)
table(df$Research.Category)
@schaunwheeler
schaunwheeler / xlsxToR.r
Last active December 11, 2020 16:41
Import an xlsx file into R by parsing the file's XML structure.
# The MIT License (MIT)
#
# Copyright (c) 2012 Schaun Jacob Wheeler
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@stephenturner
stephenturner / .Rprofile.r
Last active January 3, 2025 12:36
My .Rprofile
## See http://gettinggeneticsdone.blogspot.com/2013/06/customize-rprofile.html
## Load packages
library(BiocInstaller)
## Don't show those silly significanct stars
options(show.signif.stars=FALSE)
## Do you want to automatically convert strings to factor variables in a data.frame?
## WARNING!!! This makes your code less portable/reproducible.
@jmmateoshggm
jmmateoshggm / baplot.R
Created May 17, 2013 13:32
Bland-Altman plot, R code.
# Bland-Altman plot R function.
# Author: [email protected]
baplot <- function(m1, m2, ...) {
# m1 and m2 are the measurements
means <- (m1 + m2) / 2
diffs <- m1 - m2
mdiff <- mean(diffs)
sddiff <- sd(diffs)
# Compute the figure limits
@pssguy
pssguy / global.R
Created May 1, 2013 21:14
Shiny App showing ranking of 140+ TV Shows by episode
# load required packages
library(shiny)
library(shinyIncubator)
library(googleVis)
library(ggplot2)
library(stringr)
library(plyr)
library(XML)
library(httr)
library(Hmisc)
## load "pander" package
## http://rapporter.github.com/pander/
library(pander)
## "brew" the below file to Pandoc's markdown
Pandoc.brew('example.brew')
## or convert to HTML at one go
## NOTE: `pandoc` is needed for the conversion
Pandoc.brew('example.brew', output = tempfile(), convert = 'html')
@timelyportfolio
timelyportfolio / 2013-03-08yen-anonymous.rnw
Last active August 16, 2017 14:59
production quality R knitr latex report on yen
\documentclass[nohyper,justified]{tufte-handout}
\usepackage{xltxtra,fontspec,xunicode}
\usepackage{sectsty} %% change fonts for sections
\setmainfont{Source Sans Pro Light}
\begin{document}
\pagenumbering{gobble}
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt}
@cjbayesian
cjbayesian / intro_to_simulation.R
Created March 22, 2013 11:50
Introduction to simulation using R
#########################################################
## Intro to Simulation - R/Stats Intro Series
## Designed by: Corey Chivers, 2013
## Department of Biology, McGill University
#########################################################
##@ 0.1 @##
rm(list=ls()) # Housekeeping
#setwd('<my working directory>') # set working dir
bigcorPar <- function(x, nblocks = 10, verbose = TRUE, ncore="all", ...){
library(ff, quietly = TRUE)
require(doMC)
if(ncore=="all"){
ncore = multicore:::detectCores()
registerDoMC(cores = ncore)
} else{
registerDoMC(cores = ncore)
}