• Stars
    star
    188
  • Rank 205,563 (Top 5 %)
  • Language
    C++
  • License
    Other
  • Created about 10 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Embedded JavaScript Engine for R

V8

Embedded JavaScript and WebAssembly Engine for R

CRAN_Status_Badge CRAN RStudio mirror downloads

An R interface to V8: Google's open source JavaScript and WebAssembly engine. This package can be compiled either with V8 version 6 and up or NodeJS when built as a shared library.

Getting started

About the R package:

To see some quick examples in R run:

library(V8)
example(v8)

Installation

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

On amd64/arm64 Linux/MacOS platforms it is possible (and recommended) to automatically download a suitable static build of libv8 during package installation. This is enabled by default on Ubuntu, RHEL, and MacOS. For other systems you can opt-in by setting an environment variable DOWNLOAD_STATIC_LIBV8 during installation, for example:

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

This way, you can install the R package on any x64 Linux system, without external system requirements. Alternatively, it is also still possible to install libv8 from your distribution as described below. This may be needed for servers running other architectures, or when building the R package without internet access.

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

Fedora / Redhat

On Fedora we need v8-devel (which Fedora provides as part of nodejs):

sudo yum install v8-devel

On CentOS 7 / RHEL 7 we install first need to enable EPEL:

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

On CentOS 8 / RHEL 8, v8-devel can be installed from the nodejs:16-epel module repository:

sudo yum --refresh install @nodejs:16-epel/minimal v8-devel 

Arch Linux

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

Homebrew

On OS-X use v8 from Homebrew:

brew install v8

But it is much easier to set DOWNLOAD_STATIC_LIBV8 instead.

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)

More Repositories

1

jsonlite

A Robust, High Performance JSON Parser and Generator for R
C
361
star
2

mongolite

Fast and Simple MongoDB Client for R
C
281
star
3

curl

A Modern and Flexible Web Client for R
C
207
star
4

resttesttest

A native in-browser tool for testing REST/CORS services. Builds on jQuery and Bootstrap.
HTML
195
star
5

sys

Powerful replacements for base::system2
C
102
star
6

js

Tools for Working with JavaScript in R
R
67
star
7

openssl

OpenSSL bindings for R
R
64
star
8

RAppArmor

R interfaces to Linux and AppArmor security methods
TeX
52
star
9

protolite

Fast and Simple Object Serialization to Protocol Buffers
C++
47
star
10

opencpu-legacy

This version is no longer maintained. Switch to "opencpu" repository.
R
41
star
11

solarisvm

VMware image with R on Solaris
32
star
12

webutils

Utility functions for web applications
R
23
star
13

shinymagick

Simple Demo of using Magick with Shiny
R
22
star
14

unix

R bindings to system utilities found in most Unix systems
R
21
star
15

agent

Store sensitive data such as API tokens
R
19
star
16

gpg

Bindings to gpgme for R
C
19
star
17

bcrypt

Wrapper for bcrypt in R
C
17
star
18

webp

R bindings for libwebp
R
14
star
19

tidyhtml

R bindings to html-tidy C interface
C
14
star
20

maketools

Exploring and Testing your Toolchain Configuration and System Packages
R
14
star
21

ipfs

R bindings to IPFS
R
10
star
22

popplertest

Example code to test string encoding in poppler-cpp
C++
10
star
23

build-v8-static

Building static v8-monolith library for various distros
Dockerfile
10
star
24

imwidgets

HTML widgets for viewing images
JavaScript
9
star
25

user2021

Slides from UseR-2021 keynote presentation about R-universe
HTML
7
star
26

snapshot

Create snapshots of R package repositories
R
6
star
27

rjade

R Bindings to the Jade Templating Engine
R
6
star
28

yeroon

yeroon.net webapps
JavaScript
5
star
29

badgen

R
5
star
30

betty

Some experimental rOpenSci infrastructure plumbing
R
5
star
31

Ohmage

Ohmage R package
R
5
star
32

ndjson-benchmark

Simple benchmark to compare jsonlite, ndjson, corpus
4
star
33

yeroon-setup

JavaScript
4
star
34

r-dependency-versioning

CSS
4
star
35

opencpu.tools

some tools for the opencpu project
R
4
star
36

backup

4
star
37

markdownit

Bindings to markdown-it JavaScript library
R
3
star
38

minimist

R binding to minimist JavaScript library
R
3
star
39

slides

Slides for the defense presentation
CSS
2
star
40

Mobilize

Mobilize R package
R
2
star
41

lmergm

lmergm R package
R
2
star
42

ohmage-ubuntu

ohmage-ubuntu
Shell
2
star
43

base64

R
2
star
44

debugcurl

How to debug curl (because I keep forgetting)
2
star
45

pacmantools

Tools for pacman repos
R
1
star
46

maintest

Test with main repository
HTML
1
star
47

JJcorr

Git repo for the JJcorr package
R
1
star
48

interactivity

cran-interactivity
C
1
star
49

r-security

R
1
star
50

r-universe

1
star
51

autobrew-old

Scripts for brewing static libs on CRAN MacOS builder
Roff
1
star
52

brotli

C
1
star
53

testinterrupt

Package + readme to demonstrate the user interruption problem in R
C
1
star
54

grenoble2015

Automatically exported from code.google.com/p/io-2012-slides
CSS
1
star
55

uptest

C++
1
star