This file contains 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(XML) | |
cleanGoogleTable <- function(dat, table=1, skip=0, ncols=NA, nrows=-1, header=TRUE, dropFirstCol=NA){ | |
if(!is.data.frame(dat)){ | |
dat <- dat[[table]] | |
} | |
if(is.na(dropFirstCol)) { | |
firstCol <- na.omit(dat[[1]]) | |
if(all(firstCol == ".") || all(firstCol== as.character(seq_along(firstCol)))) { | |
dat <- dat[, -1] | |
} |
This file contains 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(foreach) | |
library(doParallel) | |
# Estimate value of pi using simulation | |
mcPi <- function(n=1e6) 4 * sum( runif(n)^2 + runif(n)^2 < 1) / n | |
# Set up cluster | |
cl <- makeCluster(4) |
This file contains 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
# Create RRT repo checkpoint | |
library(RRT) | |
checkpoint("2014-08-28") | |
rrt_browse() |
This file contains 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
# Install package from CRAN | |
getOption("repos") | |
options(repos=c(CRAN="http://cran.at.r-project.org/")) | |
install.packages("miniCRAN", type="source") | |
library("miniCRAN") | |
sessionInfo() |
This file contains 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(checkpoint) | |
checkpoint("2014-09-17") |
This file contains 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
install.packages("checkpoint") | |
library("checkpoint") |
This file contains 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
# Create temporary project and set working directory | |
example_project <- paste0("~/checkpoint_example_project_", Sys.Date()) | |
dir.create(example_project, recursive = TRUE) | |
oldwd <- setwd(example_project) | |
# Write dummy code file to project | |
This file contains 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
# Run Simon Urbanek's benchmark v2.5 | |
cat("R version\n") | |
cat("=========\n") | |
print(R.version) | |
if(exists("Revo.version")) { | |
cat("Revo version") | |
cat("============") | |
print(Revo.version) |
This file contains 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
# Set MKL threads if Revolution R Open or Revolution R Enterprise is available | |
if(require("RevoUtilsMath")){ | |
setMKLthreads(4) | |
} | |
# Initialization | |
set.seed (1) |
This file contains 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
setSnapshot <- function(date){ | |
if(missing(date)) return(getOption("repos")) | |
repoDate <- paste0("http://mran.revolutionanalytics.com/snapshot/", date) | |
response <- tryCatch( | |
suppressWarnings(readLines(repoDate)), | |
error = function(e)e | |
) | |
if(inherits(response, "error")) stop(paste0("Invalid snapshot date.")) | |
options(repos = c(CRAN = repoDate)) | |
} |
OlderNewer