• Stars
    star
    302
  • Rank 138,030 (Top 3 %)
  • Language
    JavaScript
  • License
    Other
  • Created about 10 years ago
  • Updated over 2 years ago

Reviews

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

Repository Details

Three.js widgets for R and shiny

Three.js and R

Three.js widgets for R and shiny. The package includes

  • graphjs: an interactive network visualization widget
  • scatterplot3js: a 3-d scatterplot widget similar to, but more limited than, the scatterplot3d function
  • globejs: a somewhat silly widget that plots data and images on a 3-d globe

The widgets are easy to use and render directly in RStudio, in R markdown, in Shiny applications, and from command-line R via a web browser. They produce high-quality interactive visualizations with just a few lines of R code.

Visualizations optionally use accelerated WebGL graphics, falling back to non-accelerated graphics for systems without WebGL when possible.

See https://threejs.org for details on three.js.

See https://bwlewis.github.io/rthreejs for R examples.

This project is based on the htmlwidgets package. See http://htmlwidgets.org for details and links to many other visualization widgets for R.

Changes in version 0.3.4 (August, 2021)

Added a JavaScript 'program' function argument to run extra user-supplied JavaScript initialization code, see the graphjs help for examples.

New in version 0.3.0 (June, 2017)

The new 0.3.0 package version introduces major changes. The scatterplot3js() function generally works as before but with more capabilities. The graphjs() function is very different with a new API more closely tied to the igraph package.

The threejs package now depends on igraph. If you're doing serious network analysis, you're probably already using igraph (or you should be). Threejs now uses external graph layouts (either from igraph or elsewhere). This gives much greater graph layout flexibility, something I was looking for, but also removes the cute (but slow and crude) force-directed JavaScript animation previously used. To partially make up for that, several new graph animation and interaction schemes are newly available.

See https://bwlewis.github.io/rthreejs/animation/animation.html and https://bwlewis.github.io/rthreejs/advanced/advanced.html for short tutorials on the new graph animation capabilities.

Performance of graphjs() is generally much improved using extensive buffering and custom WebGL shaders where needed. See https://bwlewis.github.io/rthreejs/ego/index.html for an example.

Summary of changes

The scatterplot3js() function was substantially improved and updated.

  • The new pch option supports many point styles with size control.
  • Interactive rotation and zooming are greatly improved and panning is now supported: press and hold the right mouse button (or touch equivalent) and move the mouse to pan.
  • Mouse over labels are supported in WebGL renderings.
  • The points3d() interface has changed to support pipelining.
  • Lines are supported too, see lines3d().
  • Support for crosstalk selection handles (see demo("crosstalk", package="threejs")).
  • Set the experimental use.orbitcontrols=TRUE option for more CPU-efficient (but less fluid) rendering (good for laptops), also applies to graphjs().

The graphjs() function is completely new.

  • Greater variety of WebGL vertex rendering ("pch") options, including spheres and much higher-performance options for large graphs.
  • Graph layout is now external; for instance use one of the many superb igraph package graph layout options.
  • Graph animation is supported, see the examples.
  • Interactive (click-able) graph animation is supported, see demo(package="threejs") for examples.
  • Limited brushing is available to highlight portions of the graph, see the brush=TRUE option.
  • Support for crosstalk selection handles.

Known issues

  • RStudio on Windows systems may not be able to render the WebGL graphics emitted by threejs. RStudio users running on Windows systems may need to use the plot "pop out" button to see visualizations in an external browser. We expect this to be a temporary problem until the underlying graphics rendering system used by RStudio is updated later in 2017.
  • The fallback Canvas rendering code has diverged too much from the baseline WebGL code and no longer works. We have temporarily disabled Canvas rendering with an error message. See #67 for details.
  • Crosstalk filter handles are used in a non-standard and experimental way to control graph animation. Don't rely on this experimental feature.

Install

Use the devtools package to install threejs directly from GitHub on any R platform (Mac, Windows, Linux, ...). You'll need the 'devtools' package.

if(!require("devtools")) install.packages("devtools")
devtools::install_github("bwlewis/rthreejs")

Examples

See ?scatterplot3d for more examples and detailed help.

library(threejs)
z <- seq(-10, 10, 0.1)
x <- cos(z)
y <- sin(z)
scatterplot3js(x, y, z, color=rainbow(length(z)))

The following example plots an undirected graph with 4039 vertices and 88234 edges from the Stanford SNAP network repository http://snap.stanford.edu/data/facebook_combined.txt.gz.

data(ego)
graphjs(ego, bg="black")

The next example illustrates the globe widget by plotting the relative population of some cities using data from the R maps package on a globe. It's based on the JavaScript WebGL Globe Toolkit (https://github.com/dataarts) by the Google Creative Lab Data Arts Team.

runApp(system.file("examples/globe", package="threejs"))

For detailed help on the widgets and additional examples, see

?scatterplot3js
?globejs
?graphjs

Status

Travis CI status

More Repositories

1

irlba

Fast truncated singular value decompositions
R
126
star
2

GLM

Notes on generalized linear models
TeX
111
star
3

rredis

R client for Redis
R
93
star
4

doRedis

R/foreach Redis backend for parallel computing
R
71
star
5

irlbpy

Truncated SVD by implicitly restarted Lanczos bidiagonalization for Python Numpy
Python
58
star
6

tcor

Fast thresholded correlation mattices
R
31
star
7

iqfeed

An R package that interfaces to DTN IQFeed over TCP/IP
R
30
star
8

1000_genomes_examples

Examples using R and 1000 genomes data
R
27
star
9

duckdb_and_r

My thoughts and examples on DuckDB and R
HTML
12
star
10

r-and-singularity

Notes on R and Singularity
12
star
11

lazy.frame

Lazy person's file-backed data frame
C
11
star
12

lz4

LZ4 Data Compression and Decompression for R
C
10
star
13

writing_foreach_adapters

Tutorials, code and notes about writing R foreach adapters
HTML
9
star
14

fls

The Kalaba-Tesfatsion Flexible Least Squares method for R.
8
star
15

hclust_in_R

A pure R hierarchical clustering implementation so I can better learn the method
R
8
star
16

IRL

Implicitly restarted Lanczos methods fo R
8
star
17

correlation-regularization

A fun example of covariance shrinkage for financial time series data
8
star
18

crosstool

An experimental, very generic control/communication widget for use with the crosstalk and htmlwidgets packages.
R
8
star
19

betfair

Betfair API for R
R
7
star
20

feathercache

Simple networked object cache
C
7
star
21

future.redis

A Redis-based task queue backend for R's future system
R
7
star
22

urca

Pfaff/Stigler Unit Root and Cointegration Analysis R package
R
6
star
23

slides

Simple HTML/CSS/JS slide environment
HTML
5
star
24

python

Simple Python bindings for R derived from https://github.com/rstudio/tensorflow
5
star
25

x3dom

Tools for creating x3dom and d3.js graphics with R and Shiny
JavaScript
5
star
26

cassini

Gershgorin discs and Brauer's ovals of Cassini
JavaScript
4
star
27

shim

Simple mmap for PVFS2 and others
C
3
star
28

RSQLServer

SQL Server database interface for R on Windows
C++
3
star
29

R4P

An R library for Processing.
C
3
star
30

nvd3

Basic R interface to nvd3.js
JavaScript
3
star
31

ratlab

Tight integration between R and GNU/Octave or Matlab
C++
3
star
32

share

Trivially simple networked object cache for generic R data
C
2
star
33

2020_rstudioconf

Slides from my talk at the 2020 RStudio conference in San Francisco
HTML
2
star
34

least-squares-without-calculus

Ordinary least squares data fitting for college algebra courses
TeX
2
star
35

tir

Example time in range computation
HTML
2
star
36

doRedisWindowsService

A Windows service wrapper for the doRedis R/foreach backend
2
star
37

Feb2016_Cleveland_R_Meetup

Slides and data for the February, 2016 Cleveland R Meetup
HTML
1
star
38

R_hacker_news_dashboard

An experiment that glues the Hacker News API to R's new flex dashboard framework from RStudio
R
1
star
39

rfinance_2016

talk slides
HTML
1
star
40

dnn_notes

Miscellaneous notes on deep neural networks
HTML
1
star
41

sshg

ssh to a group of nodes
Shell
1
star
42

msft_april_2016

a few talks for Microsoft
CSS
1
star