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
## Analyze R packages for popularity, using pagerank algorithm | |
# Inspired by Antonio Piccolboni, http://piccolboni.info/2012/05/essential-r-packages.html | |
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
# 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 --------------------------------------- |
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 <- 1000 | |
cl <- makeCluster(8) |
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
# Based on archimedes spiral | |
# Inspired by https://www.youtube.com/watch?v=SEiSloE1r-A | |
# The surprising beauty of mathematics | Jonathan Matte | TEDxGreensFarmsAcademy | |
# See http://en.wikipedia.org/wiki/Archimedean_spiral | |
rotate <- function(theta){ | |
matrix( | |
c(cos(theta), -sin(theta), | |
sin(theta), cos(theta) | |
), |
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("networkD3") | |
library("igraph") | |
# Download prepared igraph file from github | |
url <- "https://github.com/andrie/cran-network-structure/blob/master/pdb/depGraph-CRAN.rds?raw=true" | |
datafile <- tempfile(fileext = ".rds") | |
download.file(url, destfile = datafile, mode = "wb") | |
gs <- readRDS(datafile) | |
# Remove all nodes with fewer than 50 edges |
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
# StackOverflow query at | |
# https://data.stackexchange.com/stackoverflow/query/338993/r-trends-questions-per-tag-per-month#resultSets | |
# Import data ------------------------------------------------------------- | |
url <- "https://data.stackexchange.com/stackoverflow/csv/437426" | |
dat <- read.csv(url) | |
dat$Month <- as.Date(dat$Month) | |
head(dat) |