filter_window {RNewsflow} | R Documentation |
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)
Arguments
g |
A document similarity network, as created with newsflow_compare or create_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.
Value
A network/graph in the igraph class
Examples
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