Example: quiz answers

Package ‘networkD3’ - The Comprehensive R Archive Network

Package networkd3 March 18, 2017 TypePackageTitleD3 JavaScript Network Graphs from RDescriptionCreates 'D3' 'JavaScript' Network , tree, dendrogram, and Sankeygraphs from 'R'. (>= 3)DependsR (>= )Importshtmlwidgets (>= ), igraph, magrittrSuggestshtmltools (>= ), jsonlite,Enhancesknitr, Allaire [aut],Peter Ellis [ctb],Christopher Gandrud [aut, cre],Kevin Kuo [ctb], Lewis [ctb],Jonathan Owen [ctb],Kenton Russell [aut],Jennifer Rogers [ctb],Charles Sese [ctb],CJ Yetman [aut]MaintainerChristopher 17:31:09 documented: networkd3 - Package ..2chordNetwork ..3chordNetworkOutput ..4dendroNetwork ..5diagonalNetwork ..7forceNetwork ..9igraph_to_networkD3 .. 12JS .. 13 MisLinks .. 14 MisNodes .. 15radialNetwork .. 15sankeyNetwork .. 17saveNetwork .. 19 SchoolsJournals .. 19simpleNetwork .. 20 Index22networkD3-packageTools for Creating D3 Network Graphs from RDescriptionCreates D3 JavaScript Network , tree, dendrogram, and Sankey graphs from an R hclust or dendrogram object into a radialNetwork an R hclust or dendrogram object into a list suitable for use by (d, root)ArgumentsdAn object of R optional name for the root node.

height height for the network graph’s frame area in pixels width numeric width for the network graph’s frame area in pixels fontSize numeric font size in pixels for the node text labels.

Tags:

  Network, Packages, The network, Package networkd3, Networkd3

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of Package ‘networkD3’ - The Comprehensive R Archive Network

1 Package networkd3 March 18, 2017 TypePackageTitleD3 JavaScript Network Graphs from RDescriptionCreates 'D3' 'JavaScript' Network , tree, dendrogram, and Sankeygraphs from 'R'. (>= 3)DependsR (>= )Importshtmlwidgets (>= ), igraph, magrittrSuggestshtmltools (>= ), jsonlite,Enhancesknitr, Allaire [aut],Peter Ellis [ctb],Christopher Gandrud [aut, cre],Kevin Kuo [ctb], Lewis [ctb],Jonathan Owen [ctb],Kenton Russell [aut],Jennifer Rogers [ctb],Charles Sese [ctb],CJ Yetman [aut]MaintainerChristopher 17:31:09 documented: networkd3 - Package ..2chordNetwork ..3chordNetworkOutput ..4dendroNetwork ..5diagonalNetwork ..7forceNetwork ..9igraph_to_networkD3 .. 12JS .. 13 MisLinks .. 14 MisNodes .. 15radialNetwork .. 15sankeyNetwork .. 17saveNetwork .. 19 SchoolsJournals .. 19simpleNetwork .. 20 Index22networkD3-packageTools for Creating D3 Network Graphs from RDescriptionCreates D3 JavaScript Network , tree, dendrogram, and Sankey graphs from an R hclust or dendrogram object into a radialNetwork an R hclust or dendrogram object into a list suitable for use by (d, root)ArgumentsdAn object of R optional name for the root node.

2 If missing, use the first argument R objects of classhclustordendrograminto a list suitable for usewith # Create a hierarchical cluster object and display with radialNetwork## dontrunhc <- hclust(dist(USArrests), "ave")radialNetwork( (hc))chordNetworkCreate Reingold-Tilford Tree Network Reingold-Tilford Tree Network (Data, height = 500, width = 500, initialOpacity = ,useTicks = 0, colourScale = c("#1f77b4", "#aec7e8", "#ff7f0e", "#ffbb78","#2ca02c", "#98df8a", "#d62728", "#ff9896", "#9467bd", "#c5b0d5", "#8c564b","#c49c94", "#e377c2", "#f7b6d2", "#7f7f7f", "#c7c7c7", "#bcbd22", "#dbdb8d","#17becf", "#9edae5"), padding = , fontSize = 14,fontFamily = "sans-serif", labels = c(), labelDistance = 30)ArgumentsDataA square matrix or data frame whose (n, m) entry represents the strength of thelink from group n to group mheightheight for the Network graph s frame area in pixels (ifNULL then height is auto-matically determined based on context)widthnumeric width for the Network graph s frame area in pixels (ifNULL then widthis automatically determined based on context)initialOpacityspecify the opacity before the user mouses over the linkuseTicksinteger number of ticks on the radial axis.

3 The default is 0 which means noticks will be the hexadecimal colours in which to display the different categories. Ifthere are fewer colours than categories, the last colour is repeated as necessary(ifNULL then defaults to D3 colour scale)paddingspecify the amount of space between adjacent categories on the outside of thegraphfontSizenumeric font size in pixels for the node text family for the node text containing labels of the categorieslabelDistanceinteger distance in pixels (px) between text labels and outer radius. The defaultis 30 .SourceMike Bostock: ## Not run:#### Data about hair colour preferences, from## <- matrix(c(11975, 1951, 8010, 1013,5871, 10048, 16145, 990,8916, 2060, 8090, 940,2868, 6171, 8045, 6907),nrow = 4)chordNetwork(Data = hairColourData,width = 500,height = 500,colourScale = c("#000000","#FFDD89","#957244","#F26223 "),labels = c("red", "brown", "blond", "gray"))## End(Not run)chordNetworkOutputShiny bindings for networkd3 widgetsDescriptionOutput and render functions for using networkd3 widgets within Shiny applications and interactiveRmd (outputId, width = "100%", height = "500px")renderchordNetwork(expr, env = (), quoted = FALSE)dendroNetworkOutput(outputId, width = "100%", height = "800px")dendroNetwork5renderDendroNetwor k(expr, env = (), quoted = FALSE)diagonalNetworkOutput(outputId, width = "100%", height = "800px")renderDiagonalNetwork(expr, env = (), quoted = FALSE)

4 ForceNetworkOutput(outputId, width = "100%", height = "500px")renderForceNetwork(expr, env = (), quoted = FALSE)radialNetworkOutput(outputId, width = "100%", height = "800px")renderRadialNetwork(expr, env = (), quoted = FALSE)sankeyNetworkOutput(outputId, width = "100%", height = "500px")renderSankeyNetwork(expr, env = (), quoted = FALSE)simpleNetworkOutput(outputId, width = "100%", height = "500px")renderSimpleNetwork(expr, env = (), quoted = FALSE)ArgumentsoutputIdoutput variable to read fromwidth, heightMust be a valid CSS unit (like"100%","400px","auto") or a number, whichwill be coerced to a string and have"px" expression that generates a networkd3 graphenvThe environment in which to quoted expression (withquote())? This is useful if you want to savean expression in a hierarchical cluster Network hierarchical cluster Network (hc, height = 500, width = 800, fontSize = 10,linkColour = "#ccc", nodeColour = "#fff", nodeStroke = "steelblue",textColour = "#111", textOpacity = , textRotate = NULL,opacity = , margins = NULL, linkType = c("elbow", "diagonal"),treeOrientation = c("horizontal", "vertical"), zoom = FALSE)6dendroNetworkArgumentshca hierarchical (hclust) cluster for the Network graph s frame area in pixelswidthnumeric width for the Network graph s frame area in pixelsfontSizenumeric font size in pixels for the node text string specifying the colour you want the link lines to be.

5 Multipleformats supported ( hexadecimal).nodeColourcharacter string specifying the colour you want the node circles to be. Multipleformats supported ( hexadecimal).nodeStrokecharacter string specifying the colour you want the node perimeter to be. Multi-ple formats supported ( hexadecimal).textColourcharacter vector or scalar specifying the colour you want the text to be beforethey are clicked. Order should match the order ofhclust$labels. Multipleformats supported ( hexadecimal).textOpacitynumeric vector or scalar of the proportion opaque you would like the text to bebefore they are clicked. rder should match the order ofhclust$ degress to rotate text for node text. Default is 0 for horizontal and 65degrees for value of the proportion opaque you would like the graph elements value or named list of plot margins (top, right, bottom, left). Set themargin appropriately to accomodate long text specifying the link type between points.

6 Options are elbow and di-agonal .treeOrientationcharacter specifying the tree orientation, Options are vertical and horizontal .zoomlogical enabling plot zoom and panSourceMike Bostock: Nelli: ## Not run:hc <- hclust(dist(USArrests), "ave")dendroNetwork(hc, height = 600)dendroNetwork(hc, treeOrientation = "vertical")dendroNetwork(hc, height = 600, linkType = "diagonal")dendroNetwork(hc, treeOrientation = "vertical", linkType = "diagonal")dendroNetwork(hc, textColour = c("red", "green", "orange")[cutree(hc, 3)],diagonalNetwork7height = 600)dendroNetwork(hc, textColour = c("red", "green", "orange")[cutree(hc, 3)],treeOrientation = "vertical")## End(Not run)diagonalNetworkCreate Reingold-Tilford Tree Network Reingold-Tilford Tree Network (List, height = NULL, width = NULL, fontSize = 10,fontFamily = "serif", linkColour = "#ccc", nodeColour = "#fff",nodeStroke = "steelblue", textColour = "#111", opacity = ,margin = NULL)

7 ArgumentsLista hierarchical list object with a root node and for the Network graph s frame area in pixels (ifNULL then height is auto-matically determined based on context)widthnumeric width for the Network graph s frame area in pixels (ifNULL then widthis automatically determined based on context)fontSizenumeric font size in pixels for the node text family for the node text string specifying the colour you want the link lines to be. Multipleformats supported ( hexadecimal).nodeColourcharacter string specifying the colour you want the node circles to be. Multipleformats supported ( hexadecimal).nodeStrokecharacter string specifying the colour you want the node perimeter to be. Multi-ple formats supported ( hexadecimal).textColourcharacter string specifying the colour you want the text to be before they areclicked. Multiple formats supported ( hexadecimal).opacitynumeric value of the proportion opaque you would like the graph elements integer or a namedlist/vectorof integers for the plot margins.

8 If usinga namedlist/vector, the positionstop,right,bottom,leftare valid. If asingle integer is provided, then the value will be assigned to the right the margin appropriately to accomodate long text E. M., and Tilford, J. S. (1981). Tidier Drawings of Trees. IEEE Transactions onSoftware Engineering, SE-7(2), Bostock: ## Not run:#### Create tree from JSON formatted data## Download JSON data# Create URL. paste0 used purely to keep within line <- paste0(" ","master/ ")## Convert to list formatFlare <- jsonlite::fromJSON(URL, simplifyDataFrame = FALSE)## Recreate Bostock example from (List = Flare, fontSize = 10, opacity = )#### Create a tree dendrogram from an R hclust objecthc <- hclust(dist(USArrests), "ave")diagonalNetwork( (hc))diagonalNetwork( (hc), fontFamily = "cursive")#### Create tree from a hierarchical R listFor an alternative structure see: <- list(name = "Canada", children = list(list(name = "Newfoundland",children = list(list(name = "St.)))))

9 John's"))),list(name = "PEI",children = list(list(name = "Charlottetown"))),list(name = "Nova Scotia",children = list(list(name = "Halifax"))),list(name = "New Brunswick",children = list(list(name = "Fredericton"))),list(name = "Quebec",children = list(list(name = "Montreal"),list(name = "Quebec City"))),list(name = "Ontario",children = list(list(name = "Toronto"),list(name = "Ottawa"))),list(name = "Manitoba",children = list(list(name = "Winnipeg"))),list(name = "Saskatchewan",children = list(list(name = "Regina"))),list(name = "Nunavuet",children = list(list(name = "Iqaluit"))),list(name = "NWT",children = list(list(name = "Yellowknife"))),list(name = "Alberta",children = list(list(name = "Edmonton"))),list(name = "British Columbia",forceNetwork9children = list(list(name = "Victoria"),list(name = "Vancouver"))),list(name = "Yukon",children = list(list(name = "Whitehorse")))))diagonalNetwork(List = CanadaPC, fontSize = 10)## End(Not run)forceNetworkCreate a D3 JavaScript force directed Network a D3 JavaScript force directed Network (Links, Nodes, Source, Target, Value, NodeID, Nodesize, Group,height = NULL, width = NULL,colourScale = JS(" ( );"), fontSize = 7,fontFamily = "serif", linkDistance = 50,linkWidth = JS("function(d) { return ( ); }"),radiusCalculation = JS(" ( )+6"), charge = -30,linkColour = "#666", opacity = , zoom = FALSE, legend = FALSE,arrows = FALSE, bounded = FALSE, opacityNoHover = 0,clickAction = NULL)ArgumentsLinksa data frame object with the links between the nodes.

10 It should include theSourceandTargetfor each link. These should be numbered starting from optionalValuevariable can be included to specify how close the nodes areto one data frame containing the node id and properties of the nodes. If no ID isspecified then the nodes must be in the same order as the Source variable columnin theLinksdata frame. Currently only a grouping variable is string naming the Network source variable in theLinksdata string naming the Network target variable in theLinksdata string naming the variable in theLinksdata frame for how wide thelinks string specifying the node IDs in theNodesdata string specifying the a column in theNodesdata frame with somevalue to vary the node radius s with. See string specifying the group of each node in theNodesdata height for the Network graph s frame area in width for the Network graph s frame area in string specifying the categorical colour scale for the nodes.


Related search queries