Skip to content

Commit cf10002

Browse files
committed
Fixing R CMD check
1 parent 53ded69 commit cf10002

File tree

5 files changed

+195
-16
lines changed

5 files changed

+195
-16
lines changed

NEWS.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# netplot 0.2-9999
22

3-
* Unvalid arguments passed to `nplot()` now raise an error.
3+
* Invalid arguments passed to `nplot()` now raise an error.
44

55
* Figures with legends are not drawn twice.
66

7+
* Values supported by `nplot()` are now included in all methods (helps with
8+
argument completion).
9+
710

811
# netplot 0.2-0
912

R/attribute-extraction.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
#' @param graph A graph object of class igraph or network.
33
#' @param attribute A character string specifying the name of the attribute.
44
#' @return A vector of the attribute values. If the attribute does not exist, an error is thrown.
5+
#' @keywords internal
56
#' @noRd
67
get_vertex_attribute <- function(graph, attribute) UseMethod("get_vertex_attribute")
78

9+
#' @keywords internal
810
get_vertex_attribute.igraph <- function(graph, attribute) {
911

1012
# Check if the attribute exists
@@ -17,6 +19,7 @@ get_vertex_attribute.igraph <- function(graph, attribute) {
1719

1820
}
1921

22+
#' @keywords internal
2023
get_vertex_attribute.network <- function(graph, attribute) {
2124

2225
# Check if the attribute exists
@@ -29,14 +32,17 @@ get_vertex_attribute.network <- function(graph, attribute) {
2932

3033
}
3134

35+
#' @keywords internal
3236
get_vertex_attribute.default <- function(graph, attribute) {
3337

3438
stop("Graph type not supported")
3539

3640
}
3741

42+
#' @keywords internal
3843
get_edge_attribute <- function(graph, attribute) UseMethod("get_edge_attribute")
3944

45+
#' @keywords internal
4046
get_edge_attribute.igraph <- function(graph, attribute) {
4147

4248
# Check if the attribute exists
@@ -49,6 +55,7 @@ get_edge_attribute.igraph <- function(graph, attribute) {
4955

5056
}
5157

58+
#' @keywords internal
5259
get_edge_attribute.network <- function(graph, attribute) {
5360

5461
# Check if the attribute exists
@@ -61,6 +68,7 @@ get_edge_attribute.network <- function(graph, attribute) {
6168

6269
}
6370

71+
#' @keywords internal
6472
get_edge_attribute.default <- function(graph, attribute) {
6573

6674
stop("Graph type not supported")

R/color_nodes_function.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
#' @keywords internal
12
color_nodes <- function(...) UseMethod("color_nodes")
23

4+
#' @keywords internal
35
color_nodes.formula <- function(formula, ...) {
46

57
# Extract the LHS of the formula
@@ -18,6 +20,7 @@ color_nodes.formula <- function(formula, ...) {
1820

1921
}
2022

23+
#' @keywords internal
2124
color_nodes.default <- function(
2225
graph,
2326
attribute,
@@ -137,6 +140,7 @@ color_nodes.default <- function(
137140

138141
#' @noRd
139142
#' @importFrom stats quantile
143+
#' @keywords internal
140144
color_nodes_legend <- function(object) {
141145

142146
# Extracting the fill legend

R/netplot.R

Lines changed: 94 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,37 @@ nplot <- function(
142142
#' @rdname nplot
143143
nplot.igraph <- function(
144144
x,
145-
layout = igraph::layout_nicely(x),
146-
vertex.size = igraph::degree(x, mode="in"),
147-
vertex.label = igraph::vertex_attr(x, "name"),
148-
edge.width = igraph::edge_attr(x, "weight"),
149-
skip.arrows = !igraph::is_directed(x),
145+
layout = igraph::layout_nicely(x),
146+
vertex.size = igraph::degree(x, mode="in"),
147+
bg.col = "transparent",
148+
vertex.nsides = 10,
149+
vertex.color = grDevices::hcl.colors(1),
150+
vertex.size.range = c(.01, .03),
151+
vertex.frame.color = NULL,
152+
vertex.rot = 0,
153+
vertex.frame.prop = .2,
154+
vertex.label = igraph::vertex_attr(x, "name"),
155+
vertex.label.fontsize = NULL,
156+
vertex.label.color = "black",
157+
vertex.label.fontfamily = "HersheySans",
158+
vertex.label.fontface = "bold",
159+
vertex.label.show = .3,
160+
vertex.label.range = c(5, 15),
161+
edge.width = igraph::edge_attr(x, "weight"),
162+
edge.width.range = c(1, 2),
163+
edge.arrow.size = NULL,
164+
edge.color = ~ ego(alpha = .1, col = "gray") + alter,
165+
edge.curvature = pi/3,
166+
edge.line.lty = "solid",
167+
edge.line.breaks = 5,
168+
sample.edges = 1,
169+
skip.vertex = FALSE,
170+
skip.edges = FALSE,
171+
skip.arrows = !igraph::is_directed(x),
172+
add = FALSE,
173+
zero.margins = TRUE,
150174
...,
151-
edgelist = NULL
175+
edgelist
152176
) {
153177

154178
if (!length(edge.width))
@@ -173,12 +197,37 @@ nplot.igraph <- function(
173197
#' @importFrom sna gplot.layout.kamadakawai
174198
nplot.network <- function(
175199
x,
176-
layout = sna::gplot.layout.kamadakawai(x, NULL),
177-
vertex.size = sna::degree(x, cmode="indegree"),
178-
vertex.label = network::get.vertex.attribute(x, "vertex.names"),
179-
skip.arrows = !network::is.directed(x),
200+
layout = sna::gplot.layout.kamadakawai(x, NULL),
201+
vertex.size = sna::degree(x, cmode="indegree"),
202+
bg.col = "transparent",
203+
vertex.nsides = 10,
204+
vertex.color = grDevices::hcl.colors(1),
205+
vertex.size.range = c(.01, .03),
206+
vertex.frame.color = NULL,
207+
vertex.rot = 0,
208+
vertex.frame.prop = .2,
209+
vertex.label = network::get.vertex.attribute(x, "vertex.names"),
210+
vertex.label.fontsize = NULL,
211+
vertex.label.color = "black",
212+
vertex.label.fontfamily = "HersheySans",
213+
vertex.label.fontface = "bold",
214+
vertex.label.show = .3,
215+
vertex.label.range = c(5, 15),
216+
edge.width = 1,
217+
edge.width.range = c(1, 2),
218+
edge.arrow.size = NULL,
219+
edge.color = ~ ego(alpha = .1, col = "gray") + alter,
220+
edge.curvature = pi/3,
221+
edge.line.lty = "solid",
222+
edge.line.breaks = 5,
223+
sample.edges = 1,
224+
skip.vertex = FALSE,
225+
skip.edges = FALSE,
226+
skip.arrows = !network::is.directed(x),
227+
add = FALSE,
228+
zero.margins = TRUE,
180229
...,
181-
edgelist = NULL
230+
edgelist
182231
) {
183232

184233
nplot.default(
@@ -196,7 +245,40 @@ nplot.network <- function(
196245
#' @export
197246
#' @rdname nplot
198247
#' @importFrom igraph graph_from_adjacency_matrix
199-
nplot.matrix <- function(x, ..., edgelist = NULL) {
248+
nplot.matrix <- function(
249+
x,
250+
layout,
251+
vertex.size = 1,
252+
bg.col = "transparent",
253+
vertex.nsides = 10,
254+
vertex.color = grDevices::hcl.colors(1),
255+
vertex.size.range = c(.01, .03),
256+
vertex.frame.color = NULL,
257+
vertex.rot = 0,
258+
vertex.frame.prop = .2,
259+
vertex.label = NULL,
260+
vertex.label.fontsize = NULL,
261+
vertex.label.color = "black",
262+
vertex.label.fontfamily = "HersheySans",
263+
vertex.label.fontface = "bold",
264+
vertex.label.show = .3,
265+
vertex.label.range = c(5, 15),
266+
edge.width = 1,
267+
edge.width.range = c(1, 2),
268+
edge.arrow.size = NULL,
269+
edge.color = ~ ego(alpha = .1, col = "gray") + alter,
270+
edge.curvature = pi/3,
271+
edge.line.lty = "solid",
272+
edge.line.breaks = 5,
273+
sample.edges = 1,
274+
skip.vertex = FALSE,
275+
skip.edges = FALSE,
276+
skip.arrows = skip.edges,
277+
add = FALSE,
278+
zero.margins = TRUE,
279+
...,
280+
edgelist
281+
) {
200282

201283
nplot.igraph(
202284
x = igraph::graph_from_adjacency_matrix(x),

man/nplot.Rd

Lines changed: 85 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)