I hereby claim:
- I am mpjdem on github.
- I am mpjdem (https://keybase.io/mpjdem) on keybase.
- I have a public key whose fingerprint is DAE3 6756 D415 3A94 9C20 4250 F3D4 70E9 DB34 7CCF
To claim this, I am signing this object:
| { | |
| "R": { | |
| "Version": "4.1.0", | |
| "Repositories": [ | |
| { | |
| "Name": "CRAN", | |
| "URL": "https://cran.rstudio.com" | |
| } | |
| ] | |
| }, |
| library(data.table) | |
| library(keypress) | |
| ## Create the universe. Well, sort of. | |
| dims <- c(49, 49) | |
| universe <- CJ(x = seq(dims[1]), y = seq(dims[2]), k = 1, cell = FALSE) | |
| universe[, cell := sample(c(FALSE, TRUE), prod(dims), TRUE)] | |
| ## Neighbourhood to consider for each cell | |
| neighbours <- CJ(xd = -1:1, yd = -1:1, k = 1)[xd != 0 | yd != 0] |
| pick_name <- function() { | |
| names <- c("Dax", "Wug", "Lep", "Sik", "Bop") | |
| sample(names)[1] | |
| } | |
| set.seed(100) | |
| print(pick_name()) # Wug | |
| print(runif(1)) # 0.4837707 | |
| pick_name <- function() { |
| library(dplyr) | |
| library(data.table) | |
| library(dtplyr) | |
| df <- data.frame(customer = sample(100000, size = 5000000, replace = TRUE), | |
| value = runif(5000000)) | |
| # dplyr | |
| t0 <- Sys.time() | |
| res_dp <- df %>% |
| #!/usr/bin/Rscript --vanilla | |
| # To install {emo}, do: remotes::install_github("hadley/emo") | |
| # commandArgs() parses arguments provided on the command line into a <list> | |
| args <- commandArgs(trailingOnly = TRUE) | |
| # Use cat() for output | |
| cat(emo::ji(args[[1]]), "\n") |
| library(Rcpp) | |
| cppFunction('NumericMatrix crossdist(NumericMatrix m1, NumericMatrix m2) { | |
| int nrow1 = m1.nrow(); | |
| int nrow2 = m2.nrow(); | |
| int ncol = m1.ncol(); | |
| if (ncol != m2.ncol()) { | |
| throw std::runtime_error("Incompatible number of dimensions"); |
I hereby claim:
To claim this, I am signing this object:
| library(Rcpp) | |
| cppFunction('NumericMatrix crossdist(NumericMatrix m1, NumericMatrix m2) { | |
| int nrow1 = m1.nrow(); | |
| int nrow2 = m2.nrow(); | |
| int ncol = m1.ncol(); | |
| if (ncol != m2.ncol()) { | |
| throw std::runtime_error("Incompatible number of dimensions"); |
| # General functions | |
| atom <- function(obj) { | |
| atom <- new.env() | |
| atom$obj <- obj | |
| atom | |
| } | |
| deref <- function(atom) { | |
| atom$obj | |
| } |
| (def user (atom {:name "John Doe" | |
| :user-state :not-subscribed})) | |
| (println user) ;; print the memory address | |
| (println (deref user)) ;; dereference the memory address, and print the value | |
| (println @user) ;; short-hand form of dereferencing | |
| (defn subscribe [user] | |
| (when (= :not-subscribed (:user-state @user)) | |
| (swap! user assoc :user-state :subscribed))) |