Skip to content

Instantly share code, notes, and snippets.

Andrie de Vries andrie

Block or report user

Report or block andrie

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@andrie
andrie / strange_attractor.R
Created Apr 17, 2019
Plotting strange attractors using `datashader` with `reticulate`
View strange_attractor.R
# Original blog post
# https://fronkonstin.com/2019/01/10/rcpp-camaron-de-la-isla-and-the-beauty-of-maths/
# For this example to work, you must have a conda environment with the datashader library
# See http://datashader.org/getting_started/index.html#installation for installation instructions
library(Rcpp)
library(reticulate)
library(dplyr)
use_condaenv("datashader", required = TRUE)
@andrie
andrie / Can you keep a secret.R
Created Jul 29, 2017
Demo of `secret` package at UseR!2017
View Can you keep a secret.R
# load the package ----------------------------------------------------
# install.packages("secret")
library(secret)
library(magrittr)
# set up local user ---------------------------------------------------
@andrie
andrie / CRAN_pkg_segmented_model.R
Created Apr 27, 2016
Segmented regression model of CRAN packages
View CRAN_pkg_segmented_model.R
library(segmented)
library(Ecdat)
library(ggplot2)
data("CRANpackages")
str(CRANpackages)
CRANpackages$Version <- as.character(CRANpackages$Version)
CRANpackages <- rbind(CRANpackages,
data.frame(Version = "3.2",
@andrie
andrie / 0-miniCRAN-SQL-server.R
Last active Sep 20, 2017
Use miniCRAN to install packages on SQL Server
View 0-miniCRAN-SQL-server.R
# Instructions for using miniCRAN to create a package repository for installing packages on SQL Server 2016
#
# 1. Create a local repository on a machine connected to the Internet
# 2. Copy the miniCRAN repository to the target machine
# 3. Install the packages on the target machine
@andrie
andrie / CRAN_pkg_history.R
Last active Jun 6, 2019
Scrapes CRAN for historical number of packages per release
View CRAN_pkg_history.R
# Scrapes CRAN archives to determine the number of packages per release
# Create a list of pages to scrape, including both archive and current
extract_url <- function(){
url <- list(
archive = "https://cran-archive.r-project.org/bin/windows/contrib/",
active = "https://cran.r-project.org/bin/windows/contrib/"
)
get_urls <- function(url){
@andrie
andrie / analysis.R
Created Dec 27, 2015
World record runing events
View analysis.R
library(ggplot2)
dat <- read.csv("world records.csv", stringsAsFactors = FALSE)
# Clean and transform the data --------------------------------------------
track <- within(dat, {
Time <- as.numeric(Time.in.hours)
Date <- as.Date(Date, format = "%d-%b-%y")
Speed <- Distance / Time
logDistance <- log10(Distance)
View install-and-try-wakefield.R
# 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,
View wakefield-example.R
library(magrittr)
library(dplyr)
library(tidyr)
library(ggplot2)
set.seed(1)
dat <- r_data_frame(12,
name,
r_series(grade, 100, relate = "+1_6")
)
View problematic-mkl-mclapply.R
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
@andrie
andrie / doSNOW.R
Created Oct 21, 2015
Progress bars with foreach and doSNOW
View doSNOW.R
library(doSNOW)
library(tcltk)
cl <- makeSOCKcluster(2)
registerDoSNOW(cl)
pb <- txtProgressBar(max=100, style=3)
progress <- function(n) setTxtProgressBar(pb, n)
opts <- list(progress=progress)
r <- foreach(i=1:100, .options.snow=opts) %dopar% {
You can’t perform that action at this time.