This vignette summarises the network visualisation in the ClickViz package.

Input Data

The input data for the function prepare_network_edges and prepare_network_vertices will need to be in the following format. Similar to the clickstreams package, the data must be read using the following function clickstreams:readClickstream(file).

Here is an example of the data format:

```r
library(ClickViz)
clickstreams[1:5]
```

In addition to the clickstream data, for the network visualisation a corresponding tibble dataframe will need to be provided with information regarding the pages. The labels will indicate that some pages are related, hence assigned the same colour in the network.

    library(ClickViz)
    labels <- c("Type1", "Type2", "Type2", "Type3")
    state <- c("H", "P", "D", "E")
    vertex_labels_example <- tibble::tibble(state=state,
                                            vertex_label=labels)

Plot Transition Matrix

The prepare_network_edges function calculates the Markov chain transition probabilities, where alpha is the minimum transition probability plotted. It finds which pages are connected and the direction of the transition from the data provided. The width and opacity of each edge in the network is proportional to the size of the probability.

The prepare_network_vertices function calculates the size and colour of each node in the graph. The size is proportional to the frequency of the page in that data. The color relates to the page labels provided.

Examples of the network visualisation of the first order Markov chain transition matrix:

```r
edges <- prepare_network_edges(clickstreams, alpha=0.01)
nodes <- prepare_network_vertices(clickstreams,
                                  vertex_labels=vertex_labels_example)
plot_transition_network(edges,
                        nodes,
                        edge_width_factor=5,
                        edge_arrow_size=0.6,
                        edge_curve_factor=0.5,
                        vertex_size_factor=1.2,
                        legend_x_position=-3.0,
                        legend_y_position=-0.5)
```

Here is a full example including an extra dataframe of page labels and large clickstream data sample in this package.

```r
library(ClickViz)
labels = c("Content", "Purchasing", "Content", "Products", "Artificial",
            "Home", "Site Information", "Profile", "Products", "Artificial",
            "Products", "Profile", "Purchasing", "Purchasing")
state <- c("A", "B", "C", "D", "E", "H", "I", "L", "P", "R", "S", "U", "X", "Y")
vertex_labels_example <- tibble::tibble(state=state,
                                        vertex_label=labels)

edges <- prepare_network_edges(clickstreams_large, alpha=0.01)
nodes <- prepare_network_vertices(clickstreams_large,
                                  vertex_labels=vertex_labels_example)
plot_transition_network(edges,
                        nodes,
                        edge_width_factor=3,
                        edge_arrow_size=0.6,
                        edge_curve_factor=0.5,
                        vertex_size_factor=0.41,
                        legend_x_position=-2.0,
                        legend_y_position=-0.5)
```


ryanjessop/ClickViz documentation built on Dec. 31, 2020, 3:14 a.m.