jsTree: Htmlwidget for the jsTree Javascript library

Description Usage Arguments Details Examples

View source: R/jsTree.R

Description

Htmlwidget for the jsTree Javascript library

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
jsTree(
  obj,
  sep = "/",
  sep_fixed = TRUE,
  core = NULL,
  tooltips = NULL,
  nodestate = NULL,
  ...,
  width = NULL,
  height = NULL,
  elementId = NULL,
  file = tempfile(pattern = "jstree-", fileext = ".html"),
  browse = TRUE
)

Arguments

obj

character, vector of directory tree

sep

character, separator for 'obj' which defines the hierarchy, Default: '/'.

sep_fixed

boolean, to treat the sep character(s) as fixed when seperating, Default: TRUE.

core

list, additional parameters to pass to core of jsTree, default: NULL

tooltips

character, named vector of tooltips for elements in the tree, Default: NULL

nodestate

boolean, vector the length of obj that initializes tree open to true values, Default: NULL

...

parameters that are passed to the vcs package (see details)

width, height

Must be a valid CSS unit (like '100%', '400px', 'auto') or a number, which will be coerced to a string and have 'px' appended.

elementId

The input slot that will be used to access the element.

file

character, html filename to save output to, Default: tempfile(pattern = 'jstree-',fileext = '.html').

browse

whether to open a browser to view the html, Default: TRUE

Details

valid core objects can be found in the jsTree javascript library api homepage.

All objects that are children of 'jstree.defaults.core' are valid inputs, except 'jstree.defaults.core.data' which is constructed internally by the R function call. The R list object is translated internally into a valid javascript object.

parameters in ... that can be passed on to the vcs package are:

remote_repo a character object that defines the remote user/repository

remote_branch character object that defines the branch of remote_repo (ussually 'master')

vcs character object that defines for vcs which version control system to attach (github, bitbucket, svn)

preview.search character object that defines a search term to initialize to in the preview pane searchbox

if remote_repo is given a preview pane of a selected file from the tree will appear to the right of the tree

preview.search is only relevant for vcs in (github,bitbucket) where file previewing is available

For more information on the vcs package go to https://github.com/yonicd/vcs

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
if(interactive()){

data(states)
data(state_bird)

#collapse columns to text (with sep "/")
nested_string <- apply(states,1,paste,collapse='/')
jsTree(nested_string)

#pass additional parameters to core
jsTree(nested_string,core=list(multiple=FALSE))

# Add tooltips to state names with the state bird 
jsTree(nested_string,tooltips = state_bird)

#initialize tree with checked boxes for certain fields
nodestate1 <- states$variable=='Area'
jsTree(nested_string,nodestate=nodestate1)

nodestate2 <- states$variable=='Area'&grepl('^M',states$state.name)
jsTree(nested_string,nodestate=nodestate2)

nodestate3 <- states$variable %in% c('Murder') & states$value >= 10
nodestate4 <- states$variable %in% c('HS.Grad') & states$value <= 55
jsTree(nested_string,nodestate=nodestate3|nodestate4)

#change the order of the hierarchy
nested_string2 <- apply(states[,c(4,1,2,3,5)],1,paste,collapse='/')

jsTree(nested_string2)

#use jsTree to visualize folder structure

jsTree(list.files(full.names = TRUE,recursive = FALSE))

## Not run: 
# This may be too long for example if running from ~.
jsTree(list.files(full.names = TRUE,recursive = TRUE))

## End(Not run)
}

jsTree documentation built on Jan. 13, 2021, 8:40 p.m.