We're excited to have you attend one of our workshops! Here's a JavaScript (re)fresher to help you get up-to-speed on some features of the language we'll be using.
JavaScript has always had var:
var name = 'Ryan'| { | |
| "name": "myCoolPlot", | |
| data: [{x: 1, y:0}, {x: 2, y: 4}] | |
| } |
| let Promise = require('bluebird'); | |
| let fs = Promise.promisifyAll(require('fs')); // adds Async() versions that return promises | |
| let path = require('path'); | |
| let _ = require('lodash'); | |
| /** Returns the number of files in the given directory. */ | |
| let countFiles = async function(dir) { | |
| let files = await fs.readdirAsync(dir); | |
| console.log(files); | |
| let paths = _.map(files, (file) => path.join(dir, file)); |
| library(MASS) | |
| library(shiny) | |
| library(mrgsolve) | |
| library(dplyr) | |
| library(magrittr) | |
| library(parallel) | |
| RNGkind("L'Ecuyer-CMRG") | |
| set.seed(101) |
| b = matrix(0, 2, 2) | |
| b[lower.tri(b, diag=T)] = as.numeric(c("1.23E-01", | |
| "0.00E+00", | |
| "1.54E-01")) |
| library(microbenchmark) | |
| library(tibble) | |
| library(future) | |
| library(dplyr) | |
| nids <- 16 | |
| sleep_times <- data_frame(REP = 1:nids, sleep_time = round(runif(nids, 0, 2), 0)) | |
| sleep_times | |
| eager_bm <- function(sleep_times) { | |
| plan(eager) |
| library(future) | |
| library(mrgsolve) | |
| library(dplyr) | |
| data(extran3) | |
| ipar <- extran3 %>% dplyr::select(ID,CL,VC,KA) %>% distinct(ID) | |
| mod <- mrgsolve:::house() | |
| plan(multiprocess) | |
| f <- list() | |
| for (ii in 1:2) { |
| ```{r} | |
| library(pbdZMQ) | |
| library(future) | |
| sim_logger <- function(rep, message = "") { | |
| context <- zmq.ctx.new() | |
| sink <- zmq.socket(context, .pbd_env$ZMQ.ST$PUSH) | |
| zmq.connect(sink, "tcp://localhost:5558") | |
| zmq.send(sink, paste("completed sim", rep, "from process", Sys.getpid(), "with message: ", message)) |
| library(ggplot2) | |
| t1<-seq(0,40,0.2) | |
| a1<-seq(from =1, to =0, length.out = length(t1)) | |
| a2<-seq(from = 1, to = 0.4, length.out = length(t1)) | |
| a3<-seq(from = 1, to = 0.6, length.out = length(t1)) | |
| df1<-data.frame(time = t1, surv = a1) | |
| df2<-data.frame(time = t1, surv = a2) | |
| df3<-data.frame(time = t1, surv = a3) |
| package main | |
| import ( | |
| "fmt" | |
| "path/filepath" | |
| "sync" | |
| "time" | |
| ) | |
| import "os" |