Skip to content

Instantly share code, notes, and snippets.

View Maddocent's full-sized avatar

Marc Maddocent

View GitHub Profile
@Maddocent
Maddocent / customCDF.Rmd
Created September 1, 2018 22:08 — forked from rmflight/customCDF.Rmd
custom CDF in R / Bioconductor
# Creating custom CDF for Affy chips in R / Bioconductor
```{r knitrOpts, echo=FALSE}
knit_hooks$set(inline = identity) # sets output for inline resutls nicely
knit_hooks$set(error = function(x, options) stop(x)) # kills knitr if there
# is an error, therefore we don't waste time generating error messages
options(save.defaults=list(compress="xz"), stringsAsFactors=FALSE)
# set up the default compression, and do NOT allow strings in data frames to become factors.
# That one is really important, and continually messes me up.
startTime <- Sys.time() # when did we start
@Maddocent
Maddocent / calc_age.r
Created December 13, 2017 14:41 — forked from mmparker/calc_age.r
Calculate years of age at a given date
# Calculate age at a given reference date
# Create an interval between the date of birth and the enrollment date;
# intervals are specific to the two dates. Periods give the actual length
# of time between those dates, so convert to period and extract the year.
calc_age <- function(birthDate, refDate = Sys.Date()) {
require(lubridate)
@Maddocent
Maddocent / Thumbs_db_killer
Created June 14, 2016 18:37 — forked from tmos/Thumbs_db_killer
A bash script that delete all microsoft-windows-files Thumbs.db in the current folder, and all the sub-directories.
#! /bin/sh
#####################################################################################################
# == Thumbs_db_killer == #
# This script delete all the Thumbs.db files on the curent folder, and on the sub-folders. #
# You can modify the $ennemy variable if you want to bulk-delete an other file (.Sync, of whatever).#
# @author : Tom Canac http://tomcanac.com/ #
# @version : 1.0 #
# @licence : CC-BY #
#####################################################################################################

TL;DR

Include this in the .Rprofile in the top-level directory of an RStudio project:

RPROJ <- list(PROJHOME = normalizePath(getwd()))
attach(RPROJ)
rm(RPROJ)
@Maddocent
Maddocent / sweave_ggplot.Rnw
Created November 4, 2015 21:47 — forked from even4void/sweave_ggplot.Rnw
How to include ggplot graphics within Sweave
% compile with
% R CMD Sweave sweave_ggplot.Rnw
% pdflatex sweave_ggplot.tex
\documentclass[t,ucs,12pt,xcolor=dvipsnames]{beamer}
\usepackage{fancyvrb}
\title{A sample Sweave demo}
\author{Author name}
\date{}
@Maddocent
Maddocent / bin_op.R
Last active August 29, 2015 14:24 — forked from seankross/bin_op.R
"%p%" <- function(left, right){
paste(left, right)
}
# Here are a few methods for getting text from PDF files. Do read through
# the instructions carefully! NOte that this code is written for Windows 7,
# slight adjustments may be needed for other OSs
# Tell R what folder contains your 1000s of PDFs
dest <- "G:/somehere/with/many/PDFs"
# make a vector of PDF file names
myfiles <- list.files(path = dest, pattern = "pdf", full.names = TRUE)