All Projects → jeroen → V8

jeroen / V8

Licence: other
Embedded JavaScript Engine for R

Programming Languages

r
7636 projects

Labels

Projects that are alternatives of or similar to V8

Crypto
Cryptocurrency Historical Market Data R Package
Stars: ✭ 112 (-27.74%)
Mutual labels:  cran
Drat
Drat R Archive Template
Stars: ✭ 127 (-18.06%)
Mutual labels:  cran
Anytime
Anything to POSIXct or Date Converter
Stars: ✭ 137 (-11.61%)
Mutual labels:  cran
Mlr
Machine Learning in R
Stars: ✭ 1,542 (+894.84%)
Mutual labels:  cran
Dharma
Diagnostics for HierArchical Regession Models
Stars: ✭ 124 (-20%)
Mutual labels:  cran
Rblpapi
R package interfacing the Bloomberg API from https://www.bloomberglabs.com/api/
Stars: ✭ 133 (-14.19%)
Mutual labels:  cran
Startup
🔧 R package: startup - Friendly R Startup Configuration
Stars: ✭ 107 (-30.97%)
Mutual labels:  cran
Matrixstats
R package: Methods that Apply to Rows and Columns of Matrices (and to Vectors)
Stars: ✭ 151 (-2.58%)
Mutual labels:  cran
Batchtools
Tools for computation on batch systems
Stars: ✭ 127 (-18.06%)
Mutual labels:  cran
Scatterd3
R scatter plot htmlwidget based on D3.js
Stars: ✭ 135 (-12.9%)
Mutual labels:  cran
Imputets
CRAN R Package: Time Series Missing Value Imputation
Stars: ✭ 114 (-26.45%)
Mutual labels:  cran
Minicran
R package to create internally consistent, mini version of CRAN
Stars: ✭ 123 (-20.65%)
Mutual labels:  cran
Pinp
Pinp Is Not PNAS -- Two-Column PDF Template
Stars: ✭ 134 (-13.55%)
Mutual labels:  cran
Rinside
Seamless embedding of R in C++ programs
Stars: ✭ 112 (-27.74%)
Mutual labels:  cran
Arules
Mining Association Rules and Frequent Itemsets with R
Stars: ✭ 139 (-10.32%)
Mutual labels:  cran
Manipulatewidget
Add More Interactivity to htmlwidgets
Stars: ✭ 110 (-29.03%)
Mutual labels:  cran
R Appveyor
Tools for using R with AppVeyor (https://appveyor.com)
Stars: ✭ 133 (-14.19%)
Mutual labels:  cran
Tableone
R package to create "Table 1", description of baseline characteristics with or without propensity score weighting
Stars: ✭ 151 (-2.58%)
Mutual labels:  cran
Latex2exp
Use LaTeX in R. More LaTeX, less plotmath!
Stars: ✭ 148 (-4.52%)
Mutual labels:  cran
D3r
d3.js helpers for R
Stars: ✭ 133 (-14.19%)
Mutual labels:  cran

V8

Embedded JavaScript Engine for R

Build Status AppVeyor Build Status CRAN_Status_Badge CRAN RStudio mirror downloads

An R interface to Google's open source JavaScript engine. This package can now be compiled either with V8 version 6+ (LTS) from nodejs or with the legacy 3.14/3.15 version of V8.

Getting started

About the R package:

Binary packages for OS-X or Windows can be installed directly from CRAN:

install.packages("V8")

On Linux you need a suitable libv8 installation, see below.

Linux: Static libv8

NEW: As of V8 3.4 there is a new option on Linux to automatically download a suitable static build of libv8 during package installation. To use this in R simply set an environment variable DOWNLOAD_STATIC_LIBV8=1, for example:

Sys.setenv(DOWNLOAD_STATIC_LIBV8 = 1)
install.packages("V8")

This way, you can install the V8 package on any x64 Linux system, without separate system requirements. We enable this by default on Travis and Github-Actions, but for local installations, you need to opt-in via the env var above.

Alternatively, it is also still possible to install libv8 from your distribution as described below.

Arch

Arch users are advised to install the v8-r package, which has been configured to work well with R. Installation can done through your preferred AUR helper such as yay, Trizen, etc. However, since V8 contains a large codebase and (re-)compilation takes a while, users may prefer to build and update it manually. For example,

## Arch
cd /tmp
yay -G v8-r   
cd v8-r
makepkg -si

Debian / Ubuntu

Installation from source on Linux requires libv8. On Ubuntu / Debian you need to install either libv8-dev, or libnode-dev. On the latest systems, libv8-dev is actually an alias for libnode-dev so they are the same:

# Debian and Ubuntu
sudo apt-get install -y libv8-dev

Backports for Xenial and Bionic

Ubuntu versions before 19.04 ship with a rather old V8 engine in libv8-dev. The R package can be compiled against this, but the engine only supports ES5, so some "modern" JavaScript syntax may not work. A lot of JS libraries these days require this.

A recent version of the V8 engine is available in libnode-dev from our the cran/v8 PPA:

# Ubuntu Xenial (16.04) and Bionic (18.04) only
sudo add-apt-repository ppa:cran/v8
sudo apt-get update
sudo apt-get install libnode-dev

After installing libnode-dev you need to reinstall the R package, and you should be good to go.

Travis CI

The above PPA is enabled by default in Travis for R 3.5 and up. You can use the following configuration to check R packges that depend on V8:

dist: xenial
addons:
  apt:
    packages: libnode-dev

You should delete the travis repository package cache if you switch from libv8-dev to libnode-dev.

The .travis.yml in the V8 repository shows other possible configurations.

Fedora / Redhat

On Fedora we need v8-devel:

sudo yum install v8-devel

On CentOS / RHEL we install v8-devel via EPEL:

sudo yum install epel-release
sudo yum install v8-devel

Not that on CentOS / RHEL 8, you first need to enable the node:13 module repository:

# Needed on EPEL 8 only
yum install epel-release 
yum module enable nodejs:13
yum install v8-devel

Homebrew

On OS-X use v8 from Homebrew:

brew install v8

On other systems you might need to install libv8 from source.

Hello World

# Create a new context
library(V8)
ctx <- v8()

# Evaluate some code
ctx$eval("var foo = 123")
ctx$eval("var bar = 456")
ctx$eval("foo+bar")

# Assign / get objects
ctx$assign("foo", JS("function(x){return x*x}"))
ctx$assign("bar", JS("foo(9)"))
ctx$get("bar")

Call functions from JavaScript libraries

ctx <- V8::v8()
ctx$source("https://cdnjs.cloudflare.com/ajax/libs/coffee-script/1.4.0/coffee-script.min.js")
jscode <- ctx$call("CoffeeScript.compile", "square = (x) -> x * x", list(bare = TRUE))
ctx$eval(jscode)
ctx$call("square", 9)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].