With V8
from Jeroen Ooms, we can do things like use R
totest this Javascript stats library simple-statistics
from Tom McWright.
Last active
August 29, 2015 14:15
-
-
Save timelyportfolio/8f8d94d59ab52ebc81b4 to your computer and use it in GitHub Desktop.
R tests Javascript simple-statistics with V8
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
# check simple-statistics with R | |
# https://github.com/tmcw/simple-statistics | |
library(V8) | |
library(jsonlite) | |
ct = new_context("window") | |
ct$source("https://raw.githubusercontent.com/tmcw/simple-statistics/master/src/simple_statistics.js") | |
coef(lm( mpg ~ wt, mtcars )) | |
ct$eval( | |
sprintf(" | |
var lm = ss.linear_regression() | |
.data(%s); | |
[ lm.b(), lm.m() ] | |
",toJSON(lapply(1:nrow(mtcars),function(x){c(mtcars$wt[x],mtcars$mpg[x])})) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cool! Here is a slightly more cleaned up version: https://gist.github.com/jeroenooms/a5b07a669285da699056