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
# 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) |
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(igraph) | |
# Download prepared igraph file from github | |
gs <- readRDS("pdb/depGraph-CRAN.rds") | |
set.seed(42) | |
# Compute communities (clusters) | |
cl <- walktrap.community(gs, steps = 5) | |
cl$degree <- (degree(gs)[cl$names]) |
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(parallel) | |
set.seed(1) | |
m <- 10000 | |
n <- 2000 | |
A <- matrix(runif (m*n),m,n) | |
setMKLthreads(1) | |
system.time(S <- svd (A,nu=0,nv=0)) | |
# user system elapsed |
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(magrittr) | |
library(dplyr) | |
library(tidyr) | |
library(ggplot2) | |
set.seed(1) | |
dat <- r_data_frame(12, | |
name, | |
r_series(grade, 100, relate = "+1_6") | |
) |
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
# 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
# Install from github ---------------- | |
# install.packages(c("chron", "ggplot2", "dplyr", "stringi")) | |
# devtools::install_github("trinker/wakefield") | |
# Create a sample data frame --------- | |
library(wakefield) | |
r_data_frame( | |
n = 500, | |
id, |
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
# load the package ---------------------------------------------------- | |
# install.packages("secret") | |
library(secret) | |
library(magrittr) | |
# set up local user --------------------------------------------------- |