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
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
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)) | |
} |
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
# Computing the probability of drawing two identical | |
# numbers out of a hat | |
# Incorrect - binomial distribution --------------------------------------- | |
# Use pbinom() to compute a probability curve for binomial | |
# distribution |
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
## Determine CRAN package clusters (communities) | |
library(miniCRAN) | |
library(igraph) | |
library(magrittr) | |
# Download matrix of available packages at specific date ------------------ |
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
# Wrapper around available.packages --------------------------------------- | |
index <- function(url, type="source", filters=NULL){ | |
contribUrl <- contrib.url(url, type=type) | |
available.packages(contribUrl, type=type, filters=filters) | |
} | |
# CRAN -------------------------------------------------------------------- |
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(iterators) | |
library(doParallel) | |
library(tcltk) | |
# Choose number of iterations | |
n <- 250 | |
# In sequence, without progress bar --------------------------------------- |
OlderNewer