1
#' Filter
2
#' 
3
#' Filter nodes and/or edges.
4
#' 
5
#' @param proxy An object of class \code{sigmajsProxy} as returned by \code{\link{sigmajsProxy}}.
6
#' @param input A Shiny input.
7
#' @param var Variable to filter.
8
#' @param target Target of filter, \code{nodes}, \code{edges}, or \code{both}.
9
#' @param name Name of the filter, useful to undo the filter later on with \code{sg_filter_undo}.
10
#' @param node Node id to filter neighbours.
11
#' 
12
#' @section Functions:
13
#' \itemize{
14
#'   \item{\code{sg_filter_gt_p} Filter greater than \code{var}.}
15
#'   \item{\code{sg_filter_lt_p} Filter less than \code{var}.}
16
#'   \item{\code{sg_filter_eq_p} Filter equal to \code{var}.}
17
#'   \item{\code{sg_filter_not_eq_p} Filter not equal to \code{var}.}
18
#'   \item{\code{sg_filter_undo_p} Undo filters, accepts vector of \code{name}s.}
19
#' }
20
#' 
21
#' @return The \code{proxy} object.
22
#' 
23
#' @rdname filter
24
#' @export
25
sg_filter_gt_p <- function(proxy, input, var, target = c("nodes", "edges", "both"), name = NULL){
26
  
27 0
  if (missing(proxy))
28 0
    stop("must pass proxy", call. = FALSE)
29
  
30 0
  .test_proxy(proxy)
31
  
32 0
  message <- list(
33 0
    id = proxy$id, 
34 0
    input = input, 
35 0
    var = var,
36 0
    target = match.arg(target),
37 0
    name = name
38
  ) 
39
  
40 0
  proxy$session$sendCustomMessage("sg_filter_gt_p", message)
41
  
42 0
  return(proxy)
43
}
44

45
#' @rdname filter
46
#' @export
47
sg_filter_lt_p <- function(proxy, input, var, target = c("nodes", "edges", "both"), name = NULL){
48
  
49 0
  if (missing(proxy))
50 0
    stop("must pass proxy", call. = FALSE)
51
  
52 0
  .test_proxy(proxy)
53
  
54 0
  message <- list(
55 0
    id = proxy$id, 
56 0
    input = input, 
57 0
    var = var,
58 0
    target = match.arg(target),
59 0
    name = name
60
  ) 
61
  
62 0
  proxy$session$sendCustomMessage("sg_filter_lt_p", message)
63
  
64 0
  return(proxy)
65
}
66

67
#' @rdname filter
68
#' @export
69
sg_filter_eq_p <- function(proxy, input, var, target = c("nodes", "edges", "both"), name = NULL){
70
  
71 0
  if (missing(proxy))
72 0
    stop("must pass proxy", call. = FALSE)
73
  
74 0
  .test_proxy(proxy)
75
  
76 0
  message <- list(
77 0
    id = proxy$id, 
78 0
    input = input, 
79 0
    var = var,
80 0
    target = match.arg(target),
81 0
    name = name
82
  ) 
83
  
84 0
  proxy$session$sendCustomMessage("sg_filter_eq_p", message)
85
  
86 0
  return(proxy)
87
}
88

89
#' @rdname filter
90
#' @export
91
sg_filter_not_eq_p <- function(proxy, input, var, target = c("nodes", "edges", "both"), name = NULL){
92
  
93 0
  if (missing(proxy))
94 0
    stop("must pass proxy", call. = FALSE)
95
  
96 0
  .test_proxy(proxy)
97
  
98 0
  message <- list(
99 0
    id = proxy$id, 
100 0
    input = input, 
101 0
    var = var,
102 0
    target = match.arg(target),
103 0
    name = name
104
  ) 
105
  
106 0
  proxy$session$sendCustomMessage("sg_filter_not_eq_p", message)
107
  
108 0
  return(proxy)
109
}
110

111
#' @rdname filter
112
#' @export
113
sg_filter_undo_p <- function(proxy, name){
114
  
115 0
  if (missing(proxy) || missing(name))
116 0
    stop("must pass proxy and name", call. = FALSE)
117
  
118 0
  .test_proxy(proxy)
119
  
120 0
  message <- list(
121 0
    id = proxy$id,
122 0
    name = name
123
  ) 
124
  
125 0
  proxy$session$sendCustomMessage("sg_filter_undo_p", message)
126
  
127 0
  return(proxy)
128
}
129

130
#' @rdname filter
131
#' @export
132
sg_filter_neighbours_p <- function(proxy, node, name = NULL){
133 0
  if (missing(proxy) || missing(node))
134 0
    stop("must pass proxy and node id", call. = FALSE)
135
  
136 0
  .test_proxy(proxy)
137

138 0
  message <- list(
139 0
    id = proxy$id,
140 0
    node = node,
141 0
		name = name
142
  ) 
143
  
144 0
  proxy$session$sendCustomMessage("sg_filter_neighbours_p", message)
145
  
146 0
  return(proxy)
147
}

Read our documentation on viewing source code .

Loading