GithubHelp home page GithubHelp logo

rich-iannone / diagrammer Goto Github PK

View Code? Open in Web Editor NEW
1.7K 68.0 245.0 100.57 MB

Graph and network visualization using tabular data in R

Home Page: https://rich-iannone.github.io/DiagrammeR/

License: Other

R 100.00%
r network-graph graph visualization property-graph graph-functions

diagrammer's Introduction



CRAN status R-CMD-check Codecov test coverage Monthly Downloads Total Downloads Contributor Covenant



With the DiagrammeR package you can create, modify, analyze, and visualize network graph diagrams. The output can be incorporated into R Markdown documents, integrated with Shiny web apps, converted to other graph formats, or exported as image files.

The graph above can be created with this combination of DiagrammeR functions:

example_graph <-
  create_graph() %>%
  add_pa_graph(
    n = 50, m = 1,
    set_seed = 23
  ) %>%
  add_gnp_graph(
    n = 50, p = 1/100,
    set_seed = 23
  ) %>%
  join_node_attrs(df = get_betweenness(.)) %>%
  join_node_attrs(df = get_degree_total(.)) %>%
  colorize_node_attrs(
    node_attr_from = total_degree,
    node_attr_to = fillcolor,
    palette = "Greens",
    alpha = 90
  ) %>%
  rescale_node_attrs(
    node_attr_from = betweenness,
    to_lower_bound = 0.5,
    to_upper_bound = 1.0,
    node_attr_to = height
  ) %>%
  select_nodes_by_id(nodes = get_articulation_points(.)) %>%
  set_node_attrs_ws(node_attr = peripheries, value = 2) %>%
  set_node_attrs_ws(node_attr = penwidth, value = 3) %>%
  clear_selection() %>%
  set_node_attr_to_display(attr = NULL)
render_graph(example_graph, layout = "nicely")

DiagrammeR’s graph functions allow you to create graph objects, modify those graphs, get information from the graphs, create a series of graphs, and do many other useful things. This makes it possible to generate a network graph with data available in tabular datasets. Two specialized data frames contain node data and attributes (node data frames) and edges with associated edge attributes (edge data frames). Because the attributes are always kept alongside the node and edge definitions (within the graph object itself), we can easily work with them.

Graph Basics

Let’s create a graph object with create_graph() and add some nodes and edges to it. Each node gets a new integer ID upon creation. Each edge also gets an ID starting from 1. The pipes between functions make the whole process readable and understandable.

a_graph <-
  create_graph() %>%
  add_node() %>%
  add_node() %>%
  add_edge(from = 1, to = 2)

We can take away an edge by using delete_edge().

b_graph <- a_graph %>% delete_edge(from = 1, to = 2)

We can add a node to the graph while, at the same time, defining edges to or from existing nodes in the graph.

c_graph <- b_graph %>% add_node(from = 1, to = 2)

Viewing the graph object in the console will provide some basic information about the graph and some pointers on where to get additional information.

c_graph
#> DiagrammeR Graph // 3 nodes / 2 edges
#>   -- directed / connected / DAG / simple
#> 
#>   NODES / type: <unused> / label: <unused>                 info: `get_node_df()`
#>     -- no additional node attributes
#>   EDGES / rel: <unused>                                    info: `get_edge_df()`
#>     -- no additional edge attributes
#>   SELECTION / <none>
#>   CACHE / <none>
#>   GLOBAL ATTRS / 17 are set                 info: `get_global_graph_attr_info()`
#>   GRAPH ACTIONS / <none>
#>   GRAPH LOG / <3 actions> -> add_edge() -> delete_edge() -> add_node()

Any time we add a node or edge to the graph, we can add node or edge aesthetic or data attributes. These can be styling properties (e.g., color, shape), grouping labels (e.g., type and rel), or data values that are useful for calculations and for display purposes. Most node or edge creation functions (depending on whether they create either edges, nodes, or both) have the arguments node_aes, edge_aes, node_data, and edge_data. Using these, we can call the namesake helper functions (node_aes(), edge_aes(), node_data(), and edge_data()) to specifically target the created nodes or edges and bind attribute data. An additional benefit in using the helper functions (for the node/edge aesthetic attributes especially) is that RStudio can provide inline help on attribute names and definitions when typing node_aes( or edge_aes( and pressing the TAB key.

Here is an example of adding a node while setting its color, fillcolor, and fontcolor node aesthetic attributes, and, adding an edge with color, arrowhead, and tooltip edge aesthetic attributes. In both the add_node() and the add_edge() calls, the new node and edge were set with a value node/edge data attribute.

d_graph <-
  c_graph %>%
  add_node(
    type = "type_a",
    node_aes = node_aes(
      color = "steelblue",
      fillcolor = "lightblue",
      fontcolor = "gray35"
    ),
    node_data = node_data(
      value = 2.5
    )
  ) %>%
  add_edge(
    from = 1, to = 3,
    rel = "interacted_with",
    edge_aes = edge_aes(
      color = "red",
      arrowhead = "vee",
      tooltip = "Red Arrow"
    ),
    edge_data = edge_data(
      value = 5.2
    )
  )

Creating attributes and setting their values is often useful because we can further work with the attributes (e.g., mutate values or even use them during traversals). Furthermore, we can create aesthetic properties based on numerical or categorical data. This is important for when you want to display your graph diagram using the render_graph() function.

Don’t worry if attribute values weren’t set right during the creation of the associated nodes or edges. They are ways to set attribute values for existing nodes and edges. Functions are available for targeting the specific nodes/edges (i.e., making a selection) and other functions are used to set attribute values for the selected nodes or edges. Often, this can be the more efficient strategy as we can target nodes/edges based on their properties (e.g., degree, relationships to neighbors, etc.). Here is an example where we select a node based on its value attribute and modify its color node aesthetic attribute:

e_graph <-
  d_graph %>%
  select_nodes(conditions = value == 2.5) %>%
  set_node_attrs_ws(node_attr = fillcolor, value = "orange") %>%
  clear_selection()

To explain this a bit, we take the graph object d_graph, select only the nodes that have a node value attribute of exactly 2.5. (We now have an active node selection.) With the selected nodes, we set their node attribute fillcolor with the value orange. Then we deactivate the selection with clear_selection(). Now, if we view the graph with render_graph() we get this:

There are quite a few functions that allow you to select nodes (e.g., select_nodes(), select_nodes_by_id(), select_last_nodes_created()) and edges (e.g., select_edges(), select_edges_by_edge_id(), select_last_edges_created()). With these selections, we can apply changes using functions that end with ..._ws() (with selection). As seen, node attributes could be set/replaced with set_node_attrs_ws() but we can also mutate attributes of selected nodes (mutate_node_attrs_ws()), delete selected nodes (delete_nodes_ws()), and even create a subgraph with that selection (create_subgraph_ws()). Selections of nodes or edges can be inverted (where non-selected nodes or edges become the active selection) with invert_selection(), certain nodes/edges can be removed from the active selection with the deselect_nodes()/deselect_edges(), and any selection can and should be eventually cleared with clear_selection().

We can create a graph object and add graph primitives such as paths, cycles, and trees to it.

f_graph <-
  create_graph() %>%
  add_path(n = 3) %>%
  add_cycle(n = 4) %>%
  add_balanced_tree(k = 2, h = 2)

You can add one or more randomly generated graphs to a graph object. Here, let’s add a directed GNM graph with 10 nodes and 15 edges (the set_seed option makes the random graph reproducible).

g_graph <-
  create_graph() %>%
  add_gnm_graph(
    n = 15, m = 20,
    set_seed = 23
  )

The undirected version of this graph is can be made using:

h_graph <-
  create_graph(directed = FALSE) %>%
  add_gnm_graph(
    n = 15, m = 20,
    set_seed = 23
  )

We can view the graph using render_graph(). There are several layouts to choose from as well (e.g., nicely, tree, kk, fr, etc.).

render_graph(h_graph, layout = "fr")

Using Data from Tables to Generate a Graph

The DiagrammeR package contains a few simple datasets that help illustrate how to create a graph with table data. The node_list_1 and edge_list_1 datasets are super simple node and edge data frames that can be assembled into a graph. Let’s print them side by side to see what we’re working with.

node_list_1     edge_list_1

   id label        from to 
1   1     A     1     1  2 
2   2     B     2     1  3 
3   3     C     3     1  4 
4   4     D     4     1  9 
5   5     E     5     2  8 
6   6     F     6     2  7 
7   7     G     7     2  1 
8   8     H     8     2 10 
9   9     I     9     3  1 
10 10     J     10    3  6 
                11    3  8
                12    4  1
                13    5  7
                14    6  2
                15    6  9
                16    8  1
                17    9  3
                18    9 10
                19   10  1

To fashion this into a graph, we need to ensure that both the nodes and their attributes (in this case, just a label) are added, and, that the edges are added. Furthermore, we must map the from and the to definitions to the node id (in other cases, we may need to map relationships between text labels to the same text attribute stored in the node data frame). We can use three functions to generate a graph containing this data:

  1. create_graph()
  2. add_nodes_from_table()
  3. add_edges_from_table()

Let’s show the process in a stepwise fashion (while occasionally viewing the graph’s internal ndf and edf) so that we can understand what is actually happening. First, create the graph object with create_graph():

# Create the graph object
i_graph_1 <- create_graph()
  
# It will start off as empty
i_graph_1 %>% is_graph_empty()
#> [1] TRUE

Add nodes from a table with add_nodes_from_table():

# Add the nodes to the graph
i_graph_2 <-
  i_graph_1 %>%
  add_nodes_from_table(
    table = node_list_1,
    label_col = label
  )

Inspect the graph’s internal node data frame (ndf) with get_node_df():

# View the graph's internal node data frame
i_graph_2 %>% get_node_df()
#>    id type label id_external
#> 1   1 <NA>     A           1
#> 2   2 <NA>     B           2
#> 3   3 <NA>     C           3
#> 4   4 <NA>     D           4
#> 5   5 <NA>     E           5
#> 6   6 <NA>     F           6
#> 7   7 <NA>     G           7
#> 8   8 <NA>     H           8
#> 9   9 <NA>     I           9
#> 10 10 <NA>     J          10

The graph now has 10 nodes (no edges yet). Each node was automatically assigned an auto-incrementing id. The incoming id was also automatically renamed id_external so as to avoid duplicate column names and also to retain a column for mapping edge definitions. Now, let’s add the edges. We need to specify that the from_col in the edge_list_1 table is indeed from and that the to_col is to. The from_to_map argument expects a node attribute column that the from and to columns will map to. In this case it’s id_external. Note that while id also matches perfectly in this mapping, there may be cases where id won’t match with and id_external column (e.g., when there are existing nodes or when the node id values in the incoming table are provided in a different order, etc.).

Now, connect the graph nodes with edges from another dataset using add_edges_from_table():

# Add the edges to the graph
i_graph_3 <-
  i_graph_2 %>%
  add_edges_from_table(
    table = edge_list_1,
    from_col = from,
    to_col = to,
    from_to_map = id_external
  )

Inspect the graph’s internal edge data frame (edf) with get_edge_df():

# View the edge data frame
i_graph_3 %>% get_edge_df()
#>    id from to  rel
#> 1   1    1  2 <NA>
#> 2   2    1  3 <NA>
#> 3   3    1  4 <NA>
#> 4   4    1  9 <NA>
#> 5   5    2  8 <NA>
#> 6   6    2  7 <NA>
#> 7   7    2  1 <NA>
#> 8   8    2 10 <NA>
#> 9   9    3  1 <NA>
#> 10 10    3  6 <NA>
#> 11 11    3  8 <NA>
#> 12 12    4  1 <NA>
#> 13 13    5  7 <NA>
#> 14 14    6  2 <NA>
#> 15 15    6  9 <NA>
#> 16 16    8  1 <NA>
#> 17 17    9  3 <NA>
#> 18 18    9 10 <NA>
#> 19 19   10  1 <NA>

By supplying the name of the graph object in the console, we can get a succinct summary of the graph’s properties. Here, we see that the graph has 10 nodes and 19 edges:

i_graph_3
#> DiagrammeR Graph // 10 nodes / 19 edges
#>   -- directed / connected / simple
#> 
#>   NODES / type: <unused> / label: 10 vals - complete & unique
#>     -- 1 additional node attribute (id_external)
#>   EDGES / rel: <unused>                                    info: `get_edge_df()`
#>     -- no additional edge attributes
#>   SELECTION / <none>
#>   CACHE / <none>
#>   GLOBAL ATTRS / 17 are set                 info: `get_global_graph_attr_info()`
#>   GRAPH ACTIONS / <none>
#>   GRAPH LOG / <1 action> -> add_nodes_from_table() -> add_edges_from_table() -> ()

There are two other similar datasets included in the package (node_list_2 and edge_list_2). These contain extended attribute data. Let’s have a quick look at their column names:

colnames(node_list_2)
#> [1] "id"      "label"   "type"    "value_1" "value_2"
colnames(edge_list_2)
#> [1] "from"    "to"      "rel"     "value_1" "value_2"

Because we have unique labels in the label column, and categorical labels in the type and rel columns, we can create a property graph from this data. Like before, we can incorporate the two tables as a graph with add_nodes_from_table() and add_edges_from_table(). This time, we’ll remove the auto-generated id_external node attribute with the drop_node_attrs() function.

j_graph <- 
  create_graph() %>% 
  add_nodes_from_table(
    table = node_list_2,
    label_col = label,
    type_col = type
  ) %>%
  add_edges_from_table(
    table = edge_list_2,
    from_col = from,
    to_col = to,
    from_to_map = id_external,
    rel_col = rel
  ) %>%
  drop_node_attrs(node_attr = id_external)

Let’s again view the graph summary in the console. Note that the additional node attributes (value_1 and value_2) are present for both the nodes and the edges:

j_graph
#> DiagrammeR Graph // 10 nodes / 19 edges
#>   -- directed / connected / property graph / simple
#> 
#>   NODES / type: 2 vals - complete / label: 10 vals - complete & unique
#>     -- 2 additional node attributes (value_1, value_2)
#>   EDGES / rel: 3 vals - complete                           info: `get_edge_df()`
#>     -- 2 additional edge attributes (value_1, value_2)
#>   SELECTION / <none>
#>   CACHE / <none>
#>   GLOBAL ATTRS / 17 are set                 info: `get_global_graph_attr_info()`
#>   GRAPH ACTIONS / <none>
#>   GRAPH LOG / <3 actions> -> add_edges_from_table() -> () -> drop_node_attrs()

Now, because we have node/edge metadata (categorical labels and numerical data in value_1 & value_2 for both nodes and edges), we can do some interesting things with the graph. First, let’s do some mutation with mutate_node_attrs() and mutate_edge_attrs() and get the sums of value_1 and value_2 as value_3 (for both the nodes and the edges). Then, let’s color the nodes and edges forestgreen if value_3 is greater than 10 (red otherwise). Finally, let’s display the values of value_3 for the nodes when rendering the graph diagram. Here we go!

k_graph <-
  j_graph %>%
  mutate_node_attrs(value_3 = value_1 + value_2) %>%
  mutate_edge_attrs(value_3 = value_1 + value_2) %>%
  select_nodes(conditions = value_3 > 10) %>%
  set_node_attrs_ws(node_attr = fillcolor, value = "forestgreen") %>%
  invert_selection() %>%
  set_node_attrs_ws(node_attr = fillcolor, value = "red") %>%
  select_edges(conditions = value_3 > 10) %>%
  set_edge_attrs_ws(edge_attr = color, value = "forestgreen") %>%
  invert_selection() %>%
  set_edge_attrs_ws(edge_attr = color, value = "red") %>%
  clear_selection() %>%
  set_node_attr_to_display(attr = value_3)
render_graph(k_graph)

A Network Graph Example

Let’s create a property graph that pertains to contributors to three software projects. This graph has nodes representing people and projects. The attributes name, age, join_date, email, follower_count, following_count, and starred_count are specific to the person nodes while the project, start_date, stars, and language attributes apply to the project nodes. The edges represent the relationships between the people and the project.

The example graph file repository.dgr is available in the extdata/example_graphs_dgr/ directory in the DiagrammeR package (currently, only for the GitHub version). We can load it into memory by using the open_graph() function, where system.file() helps to provide the location of the file within the package.

# Load in a the small repository graph
graph <-
  open_graph(
    system.file(
      "extdata/example_graphs_dgr/repository.dgr",
      package = "DiagrammeR"
    )
  )

We can always view this property graph with the render_graph() function:

render_graph(graph, layout = "kk")

Now that the graph is set up, you can create queries with magrittr pipelines to get specific answers from the graph.

Get the average age of all the contributors. Select all nodes of type person (not project). Each node of that type has non-NA age attribute, so, get that attribute as a vector with get_node_attrs_ws() and then calculate the mean with R’s mean() function.

graph %>% 
  select_nodes(conditions = type == "person") %>%
  get_node_attrs_ws(node_attr = age) %>%
  mean()
#> [1] 33.6

We can get the total number of commits to all projects. We know that all edges contain the numerical commits attribute, so, select all edges (select_edges() by itself selects all edges in the graph). After that, get a numeric vector of commits values and then get its sum() (all commits to all projects).

graph %>% 
  select_edges() %>%
  get_edge_attrs_ws(edge_attr = commits) %>%
  sum()
#> [1] 5182

Single out the one known as Josh and get his total number of commits as a maintainer and as a contributor. Start by selecting the Josh node with select_nodes(conditions = name == "Josh"). In this graph, we know that all people have an edge to a project and that edge can be of the relationship (rel) type of contributor or maintainer. We can migrate our selection from nodes to outbound edges with trav_out_edges() (and we won’t provide a condition, just all the outgoing edges from Josh will be selected). Now we have a selection of 2 edges. Get that vector of commits values with get_edge_attrs_ws() and then calculate the sum(). This is the total number of commits.

graph %>% 
  select_nodes(conditions = name == "Josh") %>%
  trav_out_edge() %>%
  get_edge_attrs_ws(edge_attr = commits) %>%
  sum()
#> [1] 227

Get the total number of commits from Louisa, just from the maintainer role though. In this case we’ll supply a condition in trav_out_edge(). This acts as a filter for the traversal and this means that the selection will be applied to only those edges where the condition is met. Although there is only a single value, we’ll still use sum() after get_edge_attrs_ws() (a good practice because we may not know the vector length, especially in big graphs).

graph %>% 
  select_nodes(conditions = name == "Louisa") %>%
  trav_out_edge(conditions = rel == "maintainer") %>%
  get_edge_attrs_ws(edge_attr = commits) %>%
  sum()
#> [1] 236

How do we do something more complex, like, get the names of people in graph above age 32? First, select all person nodes with select_nodes(conditions = type == "person"). Then, follow up with another select_nodes() call specifying age > 32. Importantly, have set_op = "intersect" (giving us the intersection of both selections).

Now that we have the starting selection of nodes we want, we need to get all values of these nodes’ name attribute as a character vector. We do this with the get_node_attrs_ws() function. After getting that vector, sort the names alphabetically with the R function sort(). Because we get a named vector, we can use unname() to not show us the names of each vector component.

graph %>% 
  select_nodes(conditions = type == "person") %>%
  select_nodes(conditions = age > 32, set_op = "intersect") %>%
  get_node_attrs_ws(node_attr = name) %>%
  sort() %>%
  unname()
#> [1] "Jack"   "Jon"    "Kim"    "Roger"  "Sheryl"

That supercalc project is progressing quite nicely. Let’s get the total number of commits from all people to that most interesting project. Start by selecting that project’s node and work backwards. Traverse to the edges leading to it with trav_in_edge(). Those edges are from committers and they all contain the commits attribute with numerical values. Get a vector of commits and then get the sum (there are 1676 commits).

graph %>% 
  select_nodes(conditions = project == "supercalc") %>%
  trav_in_edge() %>%
  get_edge_attrs_ws(edge_attr = commits) %>%
  sum()
#> [1] 1676

Kim is now a contributor to the stringbuildeR project and has made 15 new commits to that project. We can modify the graph to reflect this.

First, add an edge with add_edge(). Note that add_edge() usually relies on node IDs in from and to when creating the new edge. This is almost always inconvenient so we can instead use node labels (we know they are unique in this graph) to compose the edge, setting use_labels = TRUE.

The rel value in add_edge() was set to contributor – in a property graph we always have values set for all node type and edge rel attributes. We will set another attribute for this edge (commits) by first selecting the edge (it was the last edge made, so we can use select_last_edges_created()), then, use set_edge_attrs_ws() and provide the attribute/value pair. Finally, clear the active selections with clear_selection(). The graph is now changed, have a look.

graph <- 
  graph %>%
  add_edge(
    from = "Kim",
    to = "stringbuildeR",
    rel = "contributor"
  ) %>%
  select_last_edges_created() %>%
  set_edge_attrs_ws(edge_attr = commits, value = 15) %>%
  clear_selection()
render_graph(graph, layout = "kk")

Get all email addresses for contributors (but not maintainers) of the randomizer and supercalc88 projects. With trav_in_edge() we just want the contributer edges/commits. Once on those edges, hop back unconditionally to the people from which the edges originate with trav_out_node(). Get the email values from those selected individuals as a sorted character vector.

graph %>% 
  select_nodes(
    conditions = 
      project == "randomizer" | 
      project == "supercalc"
  ) %>%
  trav_in_edge(conditions = rel == "contributor") %>%
  trav_out_node() %>%
  get_node_attrs_ws(node_attr = email) %>%
  sort() %>%
  unname()
#> [1] "[email protected]"      "[email protected]"     
#> [3] "[email protected]"      "[email protected]"   
#> [5] "[email protected]" "[email protected]"  
#> [7] "[email protected]"

Which people have committed to more than one project? This is a matter of node degree. We know that people have edges outward and projects and edges inward. Thus, anybody having an outdegree (number of edges outward) greater than 1 has committed to more than one project. Globally, select nodes with that condition using select_nodes_by_degree("outdeg > 1"). Once getting the name attribute values from that node selection, we can provide a sorted character vector of names.

graph %>%
  select_nodes_by_degree(expressions = "outdeg > 1") %>%
  get_node_attrs_ws(node_attr = name) %>%
  sort() %>%
  unname()
#> [1] "Josh"   "Kim"    "Louisa"

Installation

DiagrammeR is used in an R environment. If you don’t have an R installation, it can be obtained from the Comprehensive R Archive Network (CRAN).

You can install the development version of DiagrammeR from GitHub using the devtools package.

devtools::install_github("rich-iannone/DiagrammeR")

Or, get it from CRAN.

install.packages("DiagrammeR")

If you encounter a bug, have usage questions, or want to share ideas to make this package better, feel free to file an issue.

Code of Conduct

Please note that the DiagrammeR project is released with a contributor code of conduct.
By participating in this project you agree to abide by its terms.

📄 License

DiagrammeR is licensed under the MIT license. See the LICENSE.md file for more details.

🏛️ Governance

This project is primarily maintained by Rich Iannone. Other authors may occasionally assist with some of these duties.


diagrammer's People

Contributors

achubaty avatar arendsee avatar atusy avatar billdenney avatar cderv avatar davisvaughan avatar erikvona avatar gaborcsardi avatar gluc avatar iwi avatar jennybc avatar jjallaire avatar jmcastagnetto avatar jonmcalder avatar kferris10 avatar lionel- avatar maelle avatar nograpes avatar olivroy avatar pommedeterresautee avatar rich-atp avatar rich-iannone avatar rpodcast avatar stibu81 avatar timelyportfolio avatar trafficonese avatar tvarju avatar tvc-amaffei avatar vnijs avatar wligtenberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

diagrammer's Issues

Adjust diagramme height and width in Shiny?

Hello,

The DiagrammeR package is great!
I try to do a diagramme using Shiny and modify the height and width using input sliders.
The app works, but moving the sliders does not affect the size of the output.
The idea would be to increase the size when the number of nodes is large.

Below is a code example.
What I am doing wrong? Do grVizOutput parameters overpass graphviz_render parameters?

Thank you for your help!

library(shiny)
library(DiagrammeR)
library(magrittr)

##------------------------------------------
## ui function

ui = shinyUI(fluidPage( 
  fluidRow(
    column(
      width=3,
      textInput('x', 'Node Name', 'a'),
      sliderInput(inputId = "height", label = "Height", min = 0, max = 1000, value = 300, step = 100),
      sliderInput(inputId = "width", label = "Width", min = 0, max = 1000, value = 300, step = 100)
    ),
    column(
      width = 8
      , grVizOutput('diagram', height = "1000px", width = "1000px")
    )
  )
)
)


##------------------------------------------
## server function

server = function(input, output){

  output$diagram <- renderGrViz({

    create_nodes(nodes = c(input$x, "b", "c", "d")) %>%
      graphviz_graph  %>% 
      graphviz_render(output = "DOT", width = input$width, height = input$height) %>%
      grViz

  })
}


##------------------------------------------
## run app

shinyApp(ui = ui, server = server)


## sessionInfo()
## R version 3.1.2 (2014-10-31)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## magrittr_1.5      DiagrammeR_0.5    shiny_0.11.1.9004

## Firefox 37.0.2

When does update is planed to be pushed in Cran

Update of Xgboost is about to be pushed on Cran. It is dependent of DiagrammeR for plotting decision trees.

Syntax changed since version 0.1 (use of mermaid function).

Therefore I need to know if you are planning to push an update very soon to Cran to update the syntax in Xgboost.

Kind regards,
Michaël

grViz with R Shiny

Hi,

First of all - amazing package. Thank you so much!

I have been trying to create a grViz network diagram using Shiny. It gives me a parser error. Any help would be most appreciated.

Given below is the code and the error

Error

Parse error on line 2:
...s_and_circles { node [shape = box, c
----------------------^
Expecting '{', '}', 'ALPHA', 'NUM', 'COLON', 'PLUS', 'EQUALS', 'MULT', 'DOT', 'BRKT', 'SPACE', 'MINUS', 'keywords', ';', '=', '[', ']', ',', ':', 'ARROW_POINT', 'ARROW_OPEN', got 'NODE'

In global.R

spec <- "
digraph boxes_and_circles {
node [shape = box, color = blue]
A; B; C; D; E
F [color = black]

node [shape = circle,
fixedsize = true,
width = 0.9] // sets as circles
1; 2; 3; 4; 5; 6; 7; 8

edge [color = gray] 
A->1; B->2
B->3 [color = red]
B->4
C->A [color = green]
1->D; E->A; 2->4; 1->5; 1->F
E->6; 4->6; 5->7; 6->7
3->8 [color = blue]

graph [overlap = true, fontsize = 10]
}

"

ui.R

library(shiny)
library(dplyr)
library(DiagrammeR)
library(shinythemes)

shinyUI(navbarPage("AInspector", id="nav",theme = shinytheme("flatly"),
tabPanel("Test",
DiagrammeROutput('gVizDiagram',height = 1200, width = 1200)
)

)) #end ShinyUI

server.R

shinyServer(function(input, output, session) {

output$gVizDiagram <- renderDiagrammeR(
DiagrammeR(diagram=spec,type="grViz",engine="neato")
)

})

Thanks

Add razor-like syntax for substituting results of evaluated R expressions (provided in a Markdown-like style as footnotes)

Begun some preliminary work on this. The idea is to allow a marker (I've chosen the double ampersand, followed by a number) to be placed in the graph spec. As numbered footnotes, R expressions are to be provided. After some basic checking, the expressions would be evaluated and the results substituted in the proper locations in the graph spec. As this evolves a bit, I'll provide a workable example. I'd like to support expressions that produce vectors, as well.

Why do this at all? Hoping that this separation of (very useful) calculation and graph specs will result in better readability and more simplicity for the user. Again, more details to come...

Not installable on OpenSuse via R console

HI

I have the following packages installed on opensuse 13.2:

S | Name | Zusammenfassung | Typ
--+--------------------------+------------------------------------------+-----------
i | libv8-3 | JavaScript Engine | Paket
i | v8 | JavaScript Engine | Paket
i | v8-devel | Development headers and libraries for v8 | Paket
i | v8-private-headers-devel | Private Development headers for v8 | Paket

but if I run as superuser

install.packages("DiagrammeR")

I get:

8.cpp:221:13: error: ‘class v8::String’ has no member named ‘WriteAscii’
mystring->WriteAscii((char_) res.begin());
^
In file included from V8.cpp:16:0:
/usr/include/v8.h: In instantiation of ‘static void
v8::NonCopyablePersistentTraits::Uncompilable() [with O = v8::Object; T = v8::Context]’:
/usr/include/v8.h:593:17: required from ‘static void
v8::NonCopyablePersistentTraits::Copy(const v8::Persistent<S, M>&,
v8::NonCopyablePersistentTraits::NonCopyablePersistent_) [with S = v8::Context; M = 0
v8::NonCopyablePersistentTraitsv8::Context; T = v8::Context;
v8::NonCopyablePersistentTraits::NonCopyablePersistent = v8::Persistentv8::Context]’
/usr/include/v8.h:5899:21: required from ‘void v8::Persistent<T, M>::Copy(const v8::Persistent<S,
M>&) [with S = v8::Context; M2 = v8::NonCopyablePersistentTraitsv8::Context; T = v8::Context; > M = v8::NonCopyablePersistentTraitsv8::Context]’
/usr/include/v8.h:658:14: required from ‘v8::Persistent<T, M>::Persistent(const v8::Persistent<T,
M>&) [with T = v8::Context; M = v8::NonCopyablePersistentTraitsv8::Context]’
V8.cpp:22:8: required from here
/usr/include/v8.h:597:5: error: cannot convert ‘v8::Primitive_’ to ‘v8::Object_ volatile’ in assignment
TYPE_CHECK(O, Primitive);
^
/usr/lib64/R/etc/Makeconf:142: rule for goal „V8.o“ failed

any idea what I am missing.

best regards

robin

class & classDef not working for mermaid graph?

d <- "graph LR

A[Hard edge] -->|Link text| B(Round edge)
B --> C{Decision}
C -->|One| D[Result one]
C -->|Two| E[Result two]

classDef test fill:#A2EB86,stroke:#777,stroke-width:4px;
class B test;
"

mermaid(d)

Graphing nested list objects for source code workflow

I was wondering if there were any more of less automatic ways to use your package to create graphs based on the logic flow of R source code (i.e., put the condition of an if statement in a diamond shaped object and use an edge to show the contents within the if block that depend on the condition being satisfied)? Not sure if this was something you were already working on or not, but thought it would be a great contribution if there was a tutorial that could show how to do something like that.

add vignette for sequence diagram

With pull #22 we add an example of a sequence diagram, but I also think it would be nice to have a dedicated vignette to offer some discussion and examples of sequence diagrams.

Reference to networkD3???

In file

#' @param expr an expression that generates a networkD3 graph
there is a reference to networkD3. I may have missed something big but it seems to me that it is another library and DiagrammeR is center on Mermaid, isn't it?

interactivity and other features

@pommedeterresautee Since Issue #7 began as a discussion about CRAN integration, I thought it would be good to start this new thread that isolates and tracks the discussion about additional features, primarily interactivity. I hope this is ok.

Does anyone know if in Shiny it's possible to collapse a branch of a generated tree? (like you click on a node and the branch after the node are collapsed)

Very little of the first round of mermaid.js development (parsing and rendering) has focused on interactivity, but there is support for callbacks within its markdown-like spec that we could use.

With mermaid.js, we already have d3 to help us, and there are quite a few collapsible, pan-zoom examples to use. Two pre-mermaid and pre-DiagrammeR for reference from R with a rpart that I had done
http://bl.ocks.org/timelyportfolio/d49cb07923eff7a75886
http://rcharts.io/viewer/?adc2dfee7aef48ce5485

error with node with name ending with "v"

e.g. :

mermaid( "graph LR; Av -->B" )

produces a html file containing this:

Parse error on line 1:
graph LR; Av -->B
-----------^
Expecting 'EOF', 'GRAPH', 'SPACE', 'DIR', 'TAGEND', 'TAGSTART', 'SEMI', 'NEWLINE', 'SQS', 'SQE', 'PS', 'PE', 'DIAMOND_START', 'DIAMOND_STOP', 'MINUS', '--', 'ARROW_POINT', 'ARROW_CIRCLE', 'ARROW_CROSS', 'ARROW_OPEN', 'PIPE', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'NUM', 'COMMA', 'ALPHA', 'COLON', 'BRKT', 'DOT', 'PLUS', 'EQUALS', 'MULT', 'TAG_START', 'TAG_END', 'QUOTE', got 'DOWN'

where with a capital V it works fine;

mermaid( "graph LR; AV -->B" )

gives me this:

mermaid

Export graph as SVG file

It would be useful to allow for export of a Graphviz and mermaid diagram to SVG. Exporting to an SVG file would be useful for importing that SVG to another application for further work (e.g., Sketch, Illustrator, and Visio all accept SVG files, I believe).

Writing the SVG markup to an R object would also be quite useful. This would be good for understanding how to generate SVG transitions and other packages using DiagrammeR could optionally use the generated SVG for other purposes.

@timelyportfolio: is there an easy way to do this? I recall that there are various export options in the documentation for viz.js. It would be great to enable an export right inside the Graphviz graph specification in the footnotes area (indeed this will have to be done for selection of the different rendering engines).

[FEATURE] automatic replacement of \n by <br />

People working on R have not to care to what tech is used to render their graph.
In a diagram you may have several lines, they will usually be separated by \n.
Unfortunately Mermaid doesn't care of \n but takes
into account.
May be it would be good to make this transformation by the R plugin.

Moreover I don't see any reason why someone would want to keep \n in the text of its diagram.

Best of all, it should take 1mn to implement the function.

Unicode test breaking graphs

Hello, I've narrowed down a row in my edge graph that prevents the graphviz_graph() function working as it has unicode characters in it.

I'm trying to regex my way out to clean up the data, but it would be nice for a graceful fail or treatment of the Unicode in the package. Here is some example problem data:

Browse[3]> edges[170:175,]
edge_from                                             edge_to arrowhead
170 p56122012                                                  it      none
171 p60080323                           Exclude GG IP VPN Struer      none
172 p60080323                              Exclude GG IP VPN USA      none
173 p60080323 Exclude GG IP VPN GeoPlay netv<U+00C3><U+00A6>rket      none
174 p60080323                           Exclude GG IP VPN Lyngby      none
175 p60080323                        Exclude GG IP VPN Singapore      none

Browse[3]> edges[173,]
    edge_from                                             edge_to arrowhead
173 p60080323 Exclude GG IP VPN GeoPlay netv<U+00C3><U+00A6>rket      none

Browse[3]> str(edges[173,])
'data.frame':   1 obs. of  3 variables:
 $ edge_from: chr "p60080323"
 $ edge_to  : chr "Exclude GG IP VPN GeoPlay netv\u00c3\u00a6rket"
 $ arrowhead: Factor w/ 1 level "none": 1

If I make a graph from 1:172 it works, but 1:173 it just displays a blank page.

Add example for use of external .mmd file as input to DiagrammeR function

Thanks @jjallaire for contributing the functionality for providing an external file (with the suggested .mmd extension) for input to the DiagrammeR function. It seems to work well enough now with the error notification. Question is whether to expose this functionality now in an example, or, wait to develop this further (and also wait for the syntax highlighting that an upcoming daily build of RStudio will offer)?

Add in support for graphviz diagrams

This is possibly a big one, and I wanted to get some opinions on this. If we add the viz.js library, we can essentially have graphviz diagrams defined using one of several layout engines like "dot", "neato", "circo", or "twopi". Graphics would be rendered as SVG. The examples of the types of diagrams using dot alone look very nice. I think that getting this in early would set the package up for great things down the road. Then, a very strong focus on documentation and ease-of-use enhancements will be needed.

Vignette not built

I have no experience with writing / building vignette, but I don't see any reference to it in the built package but I see the source file.

Do I have something special to do during the compilation?

brary/3.1'
* installing *source* package 'DiagrammeR' ...
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (DiagrammeR)

Help page:

Documentation for package ‘DiagrammeR’ version 0.01

DESCRIPTION file.
Help Pages

DiagrammeR  R + mermaid.js
DiagrammeROutput    Widget output function for use in Shiny
renderDiagrammeR    Widget render function for use in Shiny

fix duplicate svg ids assigned by mermaid

mermaid.js must have an internal counter on mermaid.init() to assign the id to the SVG container for the diagram. In DiagrammeR, we set startOnLoad = F to suspend the auto-render behavior of mermaid.js and then run mermaid.init() each time we process a widget. If only one widget then fine, but if we have >1 widget, then the mermaidChart0 gets assigned to each SVG and everything breaks. I'll probably file an issue with mermaid.js but for now, change the render behavior in DiagrammeR to suspend mermaid.init() until the last widget. However, we will likely run into trouble even with this method in a Shiny context.

reproducible example of problem:

library(DiagrammeR)
library(htmltools)

dg = DiagrammeR("graph LR; A;")

html_print(tagList(dg,dg))

Allow theming for diagrams

Allow the ability to provide an extra stylesheet that can be used for theming diagrams, instead of having to specify it all in the graph specification,

Perhaps by an additional argument that can be used to point to a CSS sheet that is loaded after the default mermaid.css,

docs for rstudio previewing / graphviz engine specification

We are planning on releasing a new RStudio Preview on Tuesday that will have the new mermaid.js and graphviz authoring features in it. Once we have this I think it would be good to provide:

(a) A link to the preview release page so that users get the right version

(b) An example (perhaps a screenshot)

(c) Perhaps update the graphviz docs on engines to show how to specify the engine directly as a graph attribute (e.g. layout = neato). This is because RStudio calls DiagrammeR with the default arguments so there's no way to preview a non-default engine unless it's specified as part of the graphviz definition.

If this is viewed as problematic we could do one other thing: allow the user to include a comment that notifies any previewer of the preferred engine. We do something similar to this for Sweave engines (this in turn was adapted from the behavior of popular LaTeX editors). e.g. you can add % !Rnw weave = knitr at the top of a Sweave document to tell us to preview it with knitr rather than Sweave. So we could do something like this:

// !Graphviz engine = neato

This is obviously one more thing to implement and learn so if it's considered generally okay to put the engine in the graphviz definition that's simpler and thus preferred. Let me know what you think either way so I can get this into the preview for Tuesday.

use the rstudioapi::versionInfo function

The rstudio package is no longer bundled with RStudio so the example in the docs might not work for users running the preview version. Rather, the function should be rstudioapi::versionInfo (the rstudioapi package is available from CRAN).

No output when use includeMarkdown in Shiny

Hi,

I am attempting to use renderUI {includeMarkdown(render(".Rmd"))} to generate a diagram.
The following Rmd is fine when ran standalone. But there's no output running through shiny.

"Index.Rmd"

library(DiagrammeR)
DiagrammeR("
  graph LR;
    A-->B;
    A-->C;
    C-->E;
    B-->D;
    C-->D;
    D-->F;
    E-->F;
")

"server.R"
library(shiny)
library(shinydashboard)
library(DiagrammeR)

function(input, output, session) {
output$ui_framework <- renderUI({
includeMarkdown(rmarkdown::render("index.Rmd",quiet=TRUE,clean=TRUE))
})
}

"ui.R"
dashboardPage(skin="black",
dashboardHeader( ),
dashboardSidebar(
sidebarMenu(
menuItem("Design Flow",tabName = "tab_framework")
)
),
dashboardBody(
tabItems(
tabItem("tab_framework",uiOutput("ui_framework"))
)
)
)

Remove semicolons from examples (they are optional line terminators)

The version of mermaid.js included in the package (and the CRAN release) doesn't require semicolons to terminate lines. Important for multiple statements in single lines but not necessary. I'll remove them from multiline examples and provide some guidance on the change.

Saving a Shiny-Graphviz plot to a png or pdf file

Hi,

I have used this package and find it extremely useful. Thank you for all the great work.

I have built a Shiny based program that makes calls to GraphViz and Mermaid using this package. Any thoughts on how I could save the output to a png or pdf file?

I recall rCharts had a call to generate a standalone html file. Do we have an equivalent call in this package to save the plot as a file?

Thanks

grViz not showing when outputting to ioslides

When including a grViz diagram in an ioslides presentation, it doesn't show. It is working fine when output is regular HTML (so not ioslides).

Example.Rmd:

---
title: "Test graphViz"
output: ioslides_presentation

---

## Using graphviz
```{r, echo=FALSE}
boxes_and_circles <- "
digraph boxes_and_circles {

  # several 'node' statements
  node [shape = box]
    A; B; C; D; E; F

  node [shape = circle,
        fixedsize = true,
        width = 0.9] // sets as circles
    1; 2; 3; 4; 5; 6; 7; 8

  # several 'edge' statements
    A->1; B->2; B->3; B->4; C->A
    1->D; E->A; 2->4; 1->5; 1->F
    E->6; 4->6; 5->7; 6->7; 3->8

  # a 'graph' statement
  graph [overlap = true, fontsize = 10]
}
"

DiagrammeR::grViz(boxes_and_circles)

Output in Chrome:

Error: No such file or directory

Output in RStudio preview:

abort() at (no stack trace available)

SessionInfo():

R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] DiagrammeR_0.4.1

loaded via a namespace (and not attached):
 [1] bitops_1.0-6      devtools_1.7.0    digest_0.6.8      evaluate_0.5.5   
 [5] formatR_1.0       htmltools_0.2.6   htmlwidgets_0.3.2 httr_0.6.1       
 [9] knitr_1.9         RCurl_1.95-4.5    RJSONIO_1.3-0     rmarkdown_0.5.1  
[13] rstudioapi_0.2    stringr_0.6.2     tools_3.1.2       yaml_2.1.13   

Bug on Windows + RStudio + IExplorer + Mermaid

There is a strange bug in Internet Explorer. When I create a graph with Mermaid on Rstudio, I see the Diagram in the Viewer (as expected).

Then I click the button to open it in a browser. On my work laptop, IE is default without a way to change it (of course).
Then... I got just that:

NoModificationAllowedError

I copy paste the link to Chrome and I see again my diagram.

I have IE 11.0.9600...
Windows 8.1 64 bits

Sorry to bring such horrible IE bugs here. May be there are other poor guys who need to use IE and will want to use DiagrammeR. However, in my specific case, I don't really care, I never use IE, but for some other, may be mandatory.

Issue exporting mermaid diagram in RStudio

I'm using RStudio Version 0.98.1103. Nothing actually saves when I use the RStudio Export function to "Save as Image." This might be a problem on RStudio's end, or I'm just experiencing some odd quirk.

Use importFrom for V8

I have added a copy of the JS function from htmlwidgets to V8. This results in a warning for DiagrammeR:

Found the following significant warnings:
Warning: replacing previous import by ‘htmlwidgets::JS’ when loading ‘DiagrammeR’

I think the easiest way to resolve this is to use importFrom(V8, new_context) instead of import(V8).

using subscripts in diagrams

Hello,

Thanks for making this great package. I have a question, not really an issue. Could someone share how to use subscripts within a diagram? I have been trying to use paste0() and expressions to do this, but I have not managed to figure it out.

All the best,
Micaela

linkStyle stroke attribute is not being rendered in htmlwidget

While the linkStyle stroke-width attributes are being rendered correctly in the example below, the stroke (color) attributes are not. All edges remain black when, according to the linkStyle, they should be red, blue, and green respectively. Using DiagrammeR_0.5.

DiagrammeR("graph LR;
A-->B;
C-->D;
E-->|This is the text|F;
linkStyle 0 stroke:red,stroke-width:2px;
linkStyle 1 stroke:green,stroke-width:4px;
linkStyle 2 stroke:blue,stroke-width:6px;")

image

SessionInfo:
R version 3.1.3 (2015-03-09)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.2 (Yosemite)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils
[5] datasets methods base

other attached packages:
[1] DiagrammeR_0.5

loaded via a namespace (and not attached):
[1] curl_0.5 digest_0.6.8
[3] htmltools_0.2.6 htmlwidgets_0.3.2
[5] jsonlite_0.9.14 Rcpp_0.11.5
[7] RJSONIO_1.3-0 rstudioapi_0.2
[9] tools_3.1.3 V8_0.5
[11] yaml_2.1.13

DiagrammeR - Multiple calls in RShiny fails

Hi,

I am finding this package very useful and have been testing its using R Shiny v0.11 quite a bit and found a strange issue. This is using Mermaid with R Shiny v0.11.

I have taken the sample R Shiny program (at the end of the README file in https://github.com/rich-iannone/DiagrammeR) and modified it to make two calls to DiagrammeR.

The output contains the raw text showing the spec for the first diagram, and draws the visual for the second spec. In other words, only one call gets executed, while for the second call it simply dumps the markdown.

The code is given below.

library(shiny)

ui = shinyUI(fluidPage(
textInput('spec', 'Diagram Spec', value = ""),
DiagrammeROutput('diagram'),
DiagrammeROutput('diagram2')
))

server = function(input, output){
output$diagram <- renderDiagrammeR(DiagrammeR(
input$spec
))
output$diagram2 <- renderDiagrammeR(DiagrammeR(
input$spec
))

}

shinyApp(ui = ui, server = server)

My session Info

sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=C LC_COLLATE=C LC_MONETARY=C LC_MESSAGES=C LC_PAPER=C LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=C LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] shinyAce_0.2.0 whisker_0.3-2 shinythemes_1.0 DiagrammeR_0.3 dplyr_0.4.1 shiny_0.11 RMySQL_0.10.1 DBI_0.3.1

loaded via a namespace (and not attached):
[1] R6_2.0.1 RJSONIO_1.3-0 Rcpp_0.11.3 assertthat_0.1 digest_0.6.8 htmltools_0.2.6 htmlwidgets_0.3.2 httpuv_1.3.2 lazyeval_0.1.10
[10] magrittr_1.5 mime_0.2 parallel_3.1.2 rstudioapi_0.2 tools_3.1.2 xtable_1.7-4 yaml_2.1.13

update to htmlwidgets

I think htmlwidgets will be the best way to wrap the mermaid.js and other javascript libraries. This will be a great example, so I will attempt to convert this in a forked repo. Let me know if you would like me to submit a pull request for the converted version. This way you can get credit for the work.

Mermaid subgraph title not showing

Not sure if this is a Mermaid issue or DiagrammeR, but the subgraph titles are not showing:

DiagrammeR("
  graph TB
         subgraph one
         a1-->a2
         end
         subgraph two
         b1-->b2
         end
         subgraph three
         c1-->c2
         end
         c1-->a2

  classDef default fill:#CCCCCC,stroke:#333,stroke-width:1px;
  classDef cluster fill:#EEEEEE,stroke:#333,stroke-width:1px;
")

My sessionInfo:

R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] DiagrammeR_0.4

loaded via a namespace (and not attached):
 [1] bitops_1.0-6      devtools_1.7.0    digest_0.6.8      evaluate_0.5.5    formatR_1.0      
 [6] htmltools_0.2.6   htmlwidgets_0.3.2 httr_0.6.1        knitr_1.9         RCurl_1.95-4.5   
[11] RJSONIO_1.3-0     rmarkdown_0.5.1   rstudio_0.98.1091 rstudioapi_0.2    stringr_0.6.2    
[16] tools_3.1.2       yaml_2.1.13   

Cran integration

I am working on a plot function for this ML package https://github.com/tqchen/xgboost (I want to plot the tree model generated). I think DiagrammeR is perfect for this job.

However it would require a new dependency from Xgboost R package to your package and I can't do it properly until your package is pushed to Cran. Therefore, do you plan to push your package to Cran?

Kind regards,
Michaël

setting seed with grViz

Hello,

I was having trouble making diagrams reproducible when using grViz and the neato engine. I tried setting start and startType attributes, using the documentation on the Graphviz website, but that didn't seem to work. I also tried setting the seed in R. Is it possible to set the seed in DiagrammeR?

Thanks in advance. The program is awesome!

Cheers,
Micaela

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.