Package collapsibletree

Similar documents
Package jstree. October 24, 2017

Package canvasxpress

Package d3plus. September 25, 2017

Package slickr. March 6, 2018

Package profvis. R topics documented:

Package scatterd3. March 10, 2018

Package vdiffr. April 27, 2018

Package pairsd3. R topics documented: August 29, Title D3 Scatterplot Matrices Version 0.1.0

Package htmltidy. September 29, 2017

Package d3heatmap. February 1, 2018

Package htmlwidgets. July 10, 2017

Package processanimater

Package htmlwidgets. February 25, 2016

Package cattonum. R topics documented: May 2, Type Package Version Title Encode Categorical Features

Package fastdummies. January 8, 2018

Package datasets.load

Package sigmanet. April 23, 2018

Package barcoder. October 26, 2018

Package regexselect. R topics documented: September 22, Version Date Title Regular Expressions in 'shiny' Select Lists

Package networkd3. December 31, Type Package Title D3 JavaScript Network Graphs from R

Package shiny.semantic

Package projector. February 27, 2018

Package shinyaframe. November 26, 2017

Package TnT. November 22, 2017

Package editdata. October 7, 2017

Package shinyfeedback

Package clipr. June 23, 2018

Package condformat. October 19, 2017

Package repec. August 31, 2018

Package tidyimpute. March 5, 2018

Package robotstxt. November 12, 2017

Package gggenes. R topics documented: November 7, Title Draw Gene Arrow Maps in 'ggplot2' Version 0.3.2

Package spark. July 21, 2017

Package d3r. January 29, 2019

Package raker. October 10, 2017

Package geojsonsf. R topics documented: January 11, Type Package Title GeoJSON to Simple Feature Converter Version 1.3.

Package ggimage. R topics documented: December 5, Title Use Image in 'ggplot2' Version 0.1.0

Package semantic.dashboard

Package messaging. May 27, 2018

Package ggimage. R topics documented: November 1, Title Use Image in 'ggplot2' Version 0.0.7

Package pwrab. R topics documented: June 6, Type Package Title Power Analysis for AB Testing Version 0.1.0

Package ECctmc. May 1, 2018

Package leaflet.minicharts

Package radix. September 17, 2018

Package deckgl. November 19, 2018

Package omu. August 2, 2018

Package clustree. July 10, 2018

Package knitrprogressbar

Package opencage. January 16, 2018

Package nonlinearicp

Package fingertipsr. May 25, Type Package Version Title Fingertips Data for Public Health

Package tibble. August 22, 2017

Package eply. April 6, 2018

Package sfc. August 29, 2016

Package spelling. December 18, 2017

Package datapasta. January 24, 2018

Package readxl. April 18, 2017

Package revealjs. R topics documented: March 13, Type Package

Package Mondrian. R topics documented: March 4, Type Package

Package WordR. September 7, 2017

Package crossword.r. January 19, 2018

Package calpassapi. August 25, 2018

Package tablehtml. November 5, 2017

Package cli. November 5, 2017

Package tfruns. February 18, 2018

Package carbonate. R topics documented: October 14, 2018

Package splithalf. March 17, 2018

Package docxtools. July 6, 2018

Package SEMrushR. November 3, 2018

Package bigreadr. R topics documented: August 13, Version Date Title Read Large Text Files

Package narray. January 28, 2018

Package mdftracks. February 6, 2017

Package qualmap. R topics documented: September 12, Type Package

Package flextable. September 5, 2017

Package jdx. R topics documented: January 9, Type Package Title 'Java' Data Exchange for 'R' and 'rjava'

Package bisect. April 16, 2018

Package pdfsearch. July 10, 2018

Package validara. October 19, 2017

Package autocogs. September 22, Title Automatic Cognostic Summaries Version 0.1.1

Package censusr. R topics documented: June 14, Type Package Title Collect Data from the Census API Version 0.0.

Package kirby21.base

Package meme. November 2, 2017

Package tidyselect. October 11, 2018

Package glue. March 12, 2019

Package rprojroot. January 3, Title Finding Files in Project Subdirectories Version 1.3-2

Package implyr. May 17, 2018

Package sankey. R topics documented: October 22, 2017

Package oec. R topics documented: May 11, Type Package

Package tabulizer. June 7, 2018

Package githubinstall

Package shinyhelper. June 21, 2018

Package strat. November 23, 2016

Package rdryad. June 18, 2018

Package loggit. April 9, 2018

Package cancensus. February 4, 2018

Package pmatch. October 19, 2018

Package rtext. January 23, 2019

Package tidytree. June 13, 2018

Package RLumShiny. June 18, 2018

Package vinereg. August 10, 2018

Transcription:

Type Package Package collapsibletree September 23, 2017 Title Interactive Collapsible Tree Diagrams using 'D3.js' Version 0.1.6 Maintainer Adeel Khan <AdeelK@gwu.edu> Description Interactive Reingold-Tilford tree diagrams created using 'D3.js', where every node can be expanded and collapsed by clicking on it. Tooltips and color gradients can be mapped to nodes using a numeric column in the source data frame. See 'collapsibletree' website for more information and examples. License GPL (>= 3 URL https://github.com/adeelk93/collapsibletree, https://adeelk93.github.io/collapsibletree/ BugReports https://github.com/adeelk93/collapsibletree/issues Encoding UTF-8 Depends R (>= 3.0.0 Imports htmlwidgets, data.tree, stats, methods Enhances knitr, shiny LazyData true RoxygenNote 6.0.1 Suggests colorspace, RColorBrewer, dplyr, testthat NeedsCompilation no Author Adeel Khan [aut, cre], Dhrumin Shah [ctb], Mike Bostock [ctb, cph] (D3.js library, http://d3js.org Repository CRAN Date/Publication 2017-09-23 17:00:31 UTC 1

2 collapsibletree R topics documented: collapsibletree....................................... 2 collapsibletree-shiny.................................... 4 collapsibletreenetwork................................... 5 collapsibletreesummary.................................. 7 Index 10 collapsibletree Create Interactive Collapsible Tree Diagrams Description Usage Interactive Reingold-Tilford tree diagram created using D3.js, where every node can be expanded and collapsed by clicking on it. collapsibletree(df,..., inputid = NULL, attribute = "leafcount", aggfun = sum, fill = "lightsteelblue", linklength = NULL, fontsize = 10, tooltip = FALSE, tooltiphtml = NULL, nodesize = NULL, collapsed = TRUE, zoomable = TRUE, width = NULL, height = NULL ## S3 method for class 'data.frame' collapsibletree(df, hierarchy, root = deparse(substitute(df, inputid = NULL, attribute = "leafcount", aggfun = sum, fill = "lightsteelblue", fillbylevel = TRUE, linklength = NULL, fontsize = 10, tooltip = FALSE, nodesize = NULL, collapsed = TRUE, zoomable = TRUE, width = NULL, height = NULL,... ## S3 method for class 'Node' collapsibletree(df, hierarchy_attribute = "level", root = df$name, inputid = NULL, attribute = "leafcount", aggfun = sum, fill = "lightsteelblue", linklength = NULL, fontsize = 10, tooltip = FALSE, tooltiphtml = NULL, nodesize = NULL, collapsed = TRUE, zoomable = TRUE, width = NULL, height = NULL,... Arguments df a data.frame from which to construct a nested list (where every row is a leaf or a preconstructed data.tree... other arguments to pass onto S3 methods that implement this generic function - collapsibletree.data.frame, collapsibletree.node inputid attribute the input slot that will be used to access the selected node (for Shiny. Will return a named list of the most recently clicked node, along with all of its parents. numeric column not listed in hierarchy that will be used for tooltips, if applicable. Defaults to leafcount, which is the cumulative count of a node s children

collapsibletree 3 aggfun fill linklength fontsize tooltip tooltiphtml nodesize collapsed zoomable width height hierarchy root Source aggregation function applied to the attribute column to determine values of parent nodes. Defaults to sum, but mean also makes sense. either a single color or a mapping of colors: For data.frame input, a vector of colors the same length as the number of nodes. By default, vector should be ordered by level, such that the root color is described first, then all the children s colors, and then all the grandchildren s colors For data.tree input, a tree attribute containing the color for each node length of the horizontal links that connect nodes in pixels. (optional, defaults to automatic sizing Applicable only for data.frame input. font size of the label text in pixels tooltip shows the node s label and attribute value. column name (possibly containing html to override default tooltip contents, allowing for more advanced customization. Applicable only for data.tree input. numeric column that will be used to determine relative node size. Default is to have a constant node size throughout. leafcount can also be used here (cumulative count of a node s children, or count (count of node s immediate children. the tree s children will start collapsed by default pan and zoom by dragging and scrolling width in pixels (optional, defaults to automatic sizing height in pixels (optional, defaults to automatic sizing a character vector of column names that define the order and hierarchy of the tree network. Applicable only for data.frame input. label for the root node fillbylevel which order to assign fill values to nodes. TRUE: Filling by level; will assign fill values to nodes vertically. FALSE: Filling by order; will assign fill values to nodes horizontally. hierarchy_attribute name of the data.tree attribute that contains hierarchy information of the tree network. Applicable only for data.tree input. Christopher Gandrud: http://christophergandrud.github.io/networkd3/. d3noob: https://bl.ocks.org/d3noob/43a860bc0024792f8803bba8ca0d5ecd. Examples collapsibletree(warpbreaks, c("wool", "tension", "breaks" # Data from US Forest Service DataMart species <- read.csv(system.file("extdata/species.csv", package = "collapsibletree" collapsibletree(df = species, c("region", "CLASS", "NAME", fill = "green"

4 collapsibletree-shiny # Visualizing the order in which the node colors are filled library(rcolorbrewer collapsibletree( warpbreaks, c("wool", "tension", fill = brewer.pal(9, "RdBu", fillbylevel = TRUE collapsibletree( warpbreaks, c("wool", "tension", fill = brewer.pal(9, "RdBu", fillbylevel = FALSE # Tooltip can be mapped to an attribute, or default to leafcount collapsibletree( warpbreaks, c("wool", "tension", "breaks", tooltip = TRUE, attribute = "breaks" # Node size can be mapped to any numeric column, or to leafcount collapsibletree( warpbreaks, c("wool", "tension", "breaks", nodesize = "breaks" # collapsibletree.node example data(acme, package="data.tree" acme$do(function(node node$cost <- data.tree::aggregate(node, attribute = "cost", aggfun = sum collapsibletree(acme, nodesize = "cost", attribute = "cost", tooltip = TRUE # Emulating collapsibletree.data.frame using collapsibletree.node species <- read.csv(system.file("extdata/species.csv", package = "collapsibletree" hierarchy <- c("region", "CLASS", "NAME" species$pathstring <- paste( "species", apply(species[,hierarchy], 1, paste, collapse = "//", sep = "//" df <- data.tree::as.node(species, pathdelimiter = "//" collapsibletree(df collapsibletree-shiny Shiny bindings for collapsibletree Description Output and render functions for using collapsibletree within Shiny applications and interactive Rmd documents.

collapsibletreenetwork 5 Usage collapsibletreeoutput(outputid, width = "100%", height = "400px" rendercollapsibletree(expr, env = parent.frame(, quoted = FALSE Arguments outputid width, height expr env quoted output variable to read from Must be a valid CSS unit (like '100%', '400px', 'auto' or a number, which will be coerced to a string and have 'px' appended. An expression that generates a collapsibletree The environment in which to evaluate expr. Is expr a quoted expression (with quote(? This is useful if you want to save an expression in a variable. Examples if(interactive( { } # Shiny Interaction shiny::runapp(system.file("examples/02shiny", package = "collapsibletree" # Interactive Gradient Mapping shiny::runapp(system.file("examples/03shiny", package = "collapsibletree" collapsibletreenetwork Create Network Interactive Collapsible Tree Diagrams Description Interactive Reingold-Tilford tree diagram created using D3.js, where every node can be expanded and collapsed by clicking on it. This function serves as a convenience wrapper for network style data frames containing the node s parent in the first column, node parent in the second column, and additional attributes in the rest of the columns. The root node is denoted by having an NA for a parent. There must be exactly 1 root. Usage collapsibletreenetwork(df, inputid = NULL, attribute = "leafcount", aggfun = sum, fill = "lightsteelblue", linklength = NULL, fontsize = 10, tooltip = TRUE, tooltiphtml = NULL, nodesize = NULL, collapsed = TRUE, zoomable = TRUE, width = NULL, height = NULL

6 collapsibletreenetwork Arguments df inputid attribute aggfun fill linklength fontsize tooltip tooltiphtml nodesize collapsed zoomable width height a network data frame (where every row is a node from which to construct a nested list First column must be the parent (NA for root node Second column must be the child Additional columns are passed on as attributes for other parameters There must be exactly 1 root node the input slot that will be used to access the selected node (for Shiny. Will return a named list of the most recently clicked node, along with all of its parents. (For collapsibletreenetwork the names of the list are tree depth numeric column not listed in hierarchy that will be used as weighting to define the color gradient across nodes. Defaults to leafcount, which colors nodes by the cumulative count of its children aggregation function applied to the attribute column to determine values of parent nodes. Defaults to sum, but mean also makes sense. either a single color or a column name with the color for each node length of the horizontal links that connect nodes in pixels. (optional, defaults to automatic sizing font size of the label text in pixels tooltip shows the node s label and attribute value. column name (possibly containing html to override default tooltip contents, allowing for more advanced customization numeric column that will be used to determine relative node size. Default is to have a constant node size throughout. leafcount can also be used here (cumulative count of a node s children, or count (count of node s immediate children. the tree s children will start collapsed by default pan and zoom by dragging and scrolling width in pixels (optional, defaults to automatic sizing height in pixels (optional, defaults to automatic sizing Source Christopher Gandrud: http://christophergandrud.github.io/networkd3/. d3noob: https://bl.ocks.org/d3noob/43a860bc0024792f8803bba8ca0d5ecd. See Also FromDataFrameNetwork for underlying function that constructs trees from the network data frame

collapsibletreesummary 7 Examples # Create a simple org chart org <- data.frame( Manager = c( NA, "Ana", "Ana", "Bill", "Bill", "Bill", "Claudette", "Claudette", "Danny", "Fred", "Fred", "Grace", "Larry", "Larry", "Nicholas", "Nicholas", Employee = c( "Ana", "Bill", "Larry", "Claudette", "Danny", "Erika", "Fred", "Grace", "Henri", "Ida", "Joaquin", "Kate", "Mindy", "Nicholas", "Odette", "Peter", Title = c( "President", "VP Operations", "VP Finance", "Director", "Director", "Scientist", "Manager", "Manager", "Jr Scientist", "Operator", "Operator", "Associate", "Analyst", "Director", "Accountant", "Accountant" collapsibletreenetwork(org, attribute = "Title" # Add in colors and sizes org$color <- org$title levels(org$color <- colorspace::rainbow_hcl(11 collapsibletreenetwork( org, attribute = "Title", fill = "Color", nodesize = "leafcount", collapsed = FALSE # Use unsplash api to add in random photos to tooltip org$tooltip <- paste0( org$employee, "<br>title: ", org$title, "<br><img src='https://source.unsplash.com/collection/385548/150x100'>" collapsibletreenetwork( org, attribute = "Title", fill = "Color", nodesize = "leafcount", tooltiphtml = "tooltip", collapsed = FALSE collapsibletreesummary Create Summary Interactive Collapsible Tree Diagrams

8 collapsibletreesummary Description Interactive Reingold-Tilford tree diagram created using D3.js, where every node can be expanded and collapsed by clicking on it. This function serves as a convenience wrapper to add color gradients to nodes either by counting that node s children (default or specifying another numeric column in the input data frame. Usage collapsibletreesummary(df, hierarchy, root = deparse(substitute(df, inputid = NULL, attribute = "leafcount", fillfun = colorspace::heat_hcl, maxpercent = 25, percentofparent = FALSE, linklength = NULL, fontsize = 10, tooltip = TRUE, nodesize = NULL, collapsed = TRUE, zoomable = TRUE, width = NULL, height = NULL,... Arguments df hierarchy root inputid attribute fillfun a data frame (where every row is a leaf from which to construct a nested list a character vector of column names that define the order and hierarchy of the tree network label for the root node the input slot that will be used to access the selected node (for Shiny. Will return a named list of the most recently clicked node, along with all of its parents. numeric column not listed in hierarchy that will be used as weighting to define the color gradient across nodes. Defaults to leafcount, which colors nodes by the cumulative count of its children function that takes its first argument and returns a vector of colors of that length. rainbow_hcl is a good example. maxpercent highest weighting percent to use in color scale mapping. All numbers above this value will be treated as the same maximum value for the sake of coloring in the nodes (but not the ordering of nodes. Setting this value too high will make it difficult to tell the difference between nodes with many children. percentofparent toggle attribute tooltip to be percent of parent rather than the actual value of attribute linklength fontsize tooltip nodesize collapsed zoomable length of the horizontal links that connect nodes in pixels. (optional, defaults to automatic sizing font size of the label text in pixels tooltip shows the node s label and attribute value. numeric column that will be used to determine relative node size. Default is to have a constant node size throughout. leafcount can also be used here (cumulative count of a node s children, or count (count of node s immediate children. the tree s children will start collapsed by default pan and zoom by dragging and scrolling

collapsibletreesummary 9 Source width height width in pixels (optional, defaults to automatic sizing height in pixels (optional, defaults to automatic sizing... other arguments passed on to fillfun, such declaring a palette for brewer.pal Christopher Gandrud: http://christophergandrud.github.io/networkd3/. d3noob: https://bl.ocks.org/d3noob/43a860bc0024792f8803bba8ca0d5ecd. Examples # Color in by number of children collapsibletreesummary(warpbreaks, c("wool", "tension", "breaks", maxpercent = 50 # Color in by the value of breaks and use the terrain_hcl gradient collapsibletreesummary( warpbreaks, c("wool", "tension", "breaks", attribute = "breaks", fillfun = colorspace::terrain_hcl, maxpercent = 50

Index brewer.pal, 9 collapsibletree, 2 collapsibletree-shiny, 4 collapsibletreenetwork, 5 collapsibletreeoutput (collapsibletree-shiny, 4 collapsibletreesummary, 7 FromDataFrameNetwork, 6 rainbow_hcl, 8 rendercollapsibletree (collapsibletree-shiny, 4 10