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
findMyId <- function() { | |
# Requires https://github.com/ROpenSciLabs/miner | |
# dig a hole one block deep and stand in it to be found | |
# returns the IDs of players standing in a hole | |
ids <- getPlayerIds() | |
holehiders <- NULL | |
for (id in ids) { | |
pos <- getPlayerPos(id, tile=TRUE) | |
surround <- getBlocks(pos[1]-1,pos[2],pos[3]-1, pos[1]+1, pos[2], pos[3]+1)[,1,] | |
inhole <- all(c(surround[1,2],surround[2,1],surround[2,3], surround[3,2])!=0) |
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(doAzureParallel) | |
# generate a credentials json file "cluster", then... | |
registerDoAzureParallel(cluster) | |
# Run 5 million option pricing simulations | |
closingPrices <- foreach(i = 1:50, .combine='c') %dopar% { | |
replicate(100000, getClosingPrice()) | |
} |
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
pbirthdaysim <- function(n, nsims=100000, feb29=TRUE) { | |
## Using nsims simulations, estimate the probability | |
## that a room of n people includes a shared birthday | |
bdays <- 1:366 | |
## Feb 29 represented as day 366 | |
## We'll sample other days 4 times as often | |
## compared to day 366 | |
probs <- c(rep(4,365),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(doParallel) | |
cl <- makeCluster(2) | |
registerDoParallel(cl) | |
bdayp <- foreach(n=1:100) %dopar% pbirthdaysim(n) | |
bdayp <- unlist(bdapy) |
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
{ | |
"name": "davidsmiDAP8", | |
"vmSize": "Standard_D2_v2", | |
"maxTasksPerNode": 8, | |
"poolSize": { | |
"dedicatedNodes": { | |
"min": 8, | |
"max": 8 | |
}, | |
"lowPriorityNodes": { |
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
{ | |
"name": "davidsmiDAP8p", | |
"vmSize": "Standard_D2_v2", | |
"maxTasksPerNode": 4, | |
"poolSize": { | |
"dedicatedNodes": { | |
"min": 0, | |
"max": 0 | |
}, | |
"lowPriorityNodes": { |
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
--- | |
title: "Outliers are a matter of opinion?" | |
author: "Antony Unwin" | |
date: ' ' | |
output: html_document | |
--- | |
```{r include=FALSE} | |
library(ggplot2) | |
library(ggthemes) | |
library(OutliersO3) |
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(tidyverse) | |
library(stringr) | |
library(stringi) | |
simplify_name <- function(n) | |
## Extract just the name, removing any quotes, and normalize accented characters | |
stri_trans_general(str_trim(str_match(n,"^[\'\"]?([^\'\",(<]+).*<")[,2]),"latin-ascii") | |
pkglist <- tools::CRAN_package_db() | |
pkglist <- tbl_df(pkglist[-40]) ## remove duplicate MD5sum column | |
pkglist %>% | |
select(Maintainer, Author, Package) %>% |
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
random_image <- function() { | |
## Return the URL random image in Wikimedia Commons | |
random_query <- paste0("https://commons.wikimedia.org/w/api.php?", | |
"action=query", | |
"&generator=random", # get a random page | |
"&grnlimit=1", # return 1 page | |
"&grnnamespace=6", # category: File | |
"&prop=imageinfo", | |
"&iiprop=url|size|extmetadata", | |
"&iiurlheight=1080", # limit images height (sometimes) |