Learn R Programming

RNewsflow (version 1.2.6)

filter_window: Filter edges from the document similarity network based on hour difference

Description

The `filter_window` function can be used to filter the document pairs (i.e. edges) using the `hour_window` parameter, which works identical to the `hour_window` parameter in the `newsflow.compare` function. In addition, the `from_vertices` and `to_vertices` parameters can be used to select the vertices (i.e. documents) for which this filter is applied.

Usage

filter_window(g, hour_window, to_vertices = NULL, from_vertices = NULL)

Value

A network/graph in the igraph class

Arguments

g

A document similarity network, as created with newsflow.compare or document.network

hour_window

A vector of length 2, in which the first and second value determine the left and right side of the window, respectively. For example, c(-10, 36) will compare each document to all documents between the previous 10 and the next 36 hours.

to_vertices

A filter to select the vertices `to` which an edge is filtered. For example, if `V(g)$sourcetype == "newspaper"` is used, then the hour_window filter is only applied for edges `to` newspaper documents (specifically, where the sourcetype attribute is "newspaper").

from_vertices

A filter to select the vertices `from` which an edge is filtered. Works identical to `to_vertices`.

Details

It is recommended to use the show_window function to verify whether the hour windows are correct according to the assumptions and focus of the study.

Examples

Run this code
data(docnet)
show_window(docnet, to_attribute = 'source') # before filtering

docnet = filter_window(docnet, hour_window = c(0.1,24))

docnet = filter_window(docnet, hour_window = c(6,36), 
                       to_vertices = V(docnet)$sourcetype == 'Print NP')

show_window(docnet, to_attribute = 'sourcetype') # after filtering per sourcetype
show_window(docnet, to_attribute = 'source') # after filtering per source

Run the code above in your browser using DataLab