Last active
August 29, 2015 14:11
-
-
Save jeroen/9e4dc12a70b7e880fbed to your computer and use it in GitHub Desktop.
Fun with V8 console
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
# Execute this script line by line in your favorite IDE | |
# It does not work via source() | |
library(V8) | |
data(diamonds, package="ggplot2") | |
# Create session | |
ct <- new_context() | |
ct$source("http://cdnjs.cloudflare.com/ajax/libs/crossfilter/1.3.11/crossfilter.min.js") | |
ct$assign("diamonds", diamonds) | |
# Enter the JavaScript console | |
ct$console() | |
//now we are in javasript :) | |
var cf = crossfilter(diamonds) | |
var price = cf.dimension(function(x){return x.price}) | |
var depth = cf.dimension(function(x){return x.depth}) | |
price.filter([2000, 3000]) | |
JSON.stringify(depth.top(10)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment