@@ -59,7 +59,7 @@ get_adjacency_submatrix <- function(x, i, j, attr = NULL) {
59
59
if (missing(i )) {
60
60
i_seq <- seq_len(vcount(x ))
61
61
has_i <- FALSE
62
- } else {
62
+ } else {
63
63
i_seq <- i
64
64
has_i <- TRUE
65
65
}
@@ -78,10 +78,10 @@ get_adjacency_submatrix <- function(x, i, j, attr = NULL) {
78
78
to_id <- unlist(adj )
79
79
80
80
edge_list <- data.frame (from = as.integer(from_id ), to = as.integer(to_id ))
81
- if (has_j ){
81
+ if (has_j ) {
82
82
edge_list <- edge_list [edge_list $ to %in% j_seq , ]
83
83
}
84
-
84
+
85
85
row_indices <- edge_list [[1 ]]
86
86
col_indices <- edge_list [[2 ]]
87
87
@@ -214,21 +214,21 @@ get_adjacency_submatrix <- function(x, i, j, attr = NULL) {
214
214
# # Argument checks
215
215
if ((! missing(from ) || ! missing(to )) &&
216
216
(! missing(i ) || ! missing(j ))) {
217
- stop (" Cannot give ' from'/'to' together with regular indices" )
217
+ cli :: cli_abort (" Cannot use {.arg from}/{.arg to} together with regular indices" )
218
218
}
219
219
if ((! missing(from ) && missing(to )) ||
220
220
(missing(from ) && ! missing(to ))) {
221
- stop (" Cannot give ' from'/'to' without the other" )
221
+ cli :: cli_abort (" Cannot use {.arg from}/{.arg to} without the other" )
222
222
}
223
223
if (! missing(from )) {
224
224
if ((! is.numeric(from ) && ! is.character(from )) || any(is.na(from ))) {
225
- stop( " ' from' must be a numeric or character vector without NAs" )
225
+ cli :: cli_abort( " {.arg from} must be a numeric or character vector without NAs" )
226
226
}
227
227
if ((! is.numeric(to ) && ! is.character(to )) || any(is.na(to ))) {
228
- stop( " 'to' must be a numeric or character vector without NAs" )
228
+ cli :: cli_abort( " {.arg to} must be a numeric or character vector without NAs" )
229
229
}
230
230
if (length(from ) != length(to )) {
231
- stop( " ' from' and 'to' must have the same length" )
231
+ cli :: cli_abort( " {.arg from} and {.arg to} must have the same length" )
232
232
}
233
233
}
234
234
@@ -286,10 +286,9 @@ get_adjacency_submatrix <- function(x, i, j, attr = NULL) {
286
286
287
287
if (! sparse ) {
288
288
as.matrix(sub_adjmat [, , drop = drop ])
289
- } else {
289
+ } else {
290
290
sub_adjmat [, , drop = drop ]
291
- }
292
-
291
+ }
293
292
}
294
293
295
294
# ' Query and manipulate a graph as it were an adjacency list
@@ -353,8 +352,8 @@ get_adjacency_submatrix <- function(x, i, j, attr = NULL) {
353
352
edges = FALSE , exact = TRUE ) {
354
353
getfun <- if (edges ) as_adj_edge_list else as_adj_list
355
354
356
- if (! missing(i ) && ! missing(from )) stop (" Cannot give both 'i' and ' from' " )
357
- if (! missing(j ) && ! missing(to )) stop (" Cannot give both 'j' and 'to' " )
355
+ if (! missing(i ) && ! missing(from )) cli :: cli_abort (" Cannot use both {.arg i} and {.arg from} " )
356
+ if (! missing(j ) && ! missing(to )) cli :: cli_abort (" Cannot use both {.arg j} and {.arg to} " )
358
357
if (missing(i ) && ! missing(from )) i <- from
359
358
if (missing(j ) && ! missing(to )) j <- to
360
359
@@ -425,28 +424,28 @@ expand.grid.unordered <- function(i, j, loops = FALSE, directed = FALSE) {
425
424
# # Argument checks
426
425
if ((! missing(from ) || ! missing(to )) &&
427
426
(! missing(i ) || ! missing(j ))) {
428
- stop (" Cannot give ' from'/'to' together with regular indices" )
427
+ cli :: cli_abort (" Cannot use {.arg from}/{.arg to} together with regular indices" )
429
428
}
430
429
if ((! missing(from ) && missing(to )) ||
431
430
(missing(from ) && ! missing(to ))) {
432
- stop (" Cannot give ' from'/'to' without the other" )
431
+ cli :: cli_abort (" Cannot use {.arg from}/{.arg to} without the other" )
433
432
}
434
433
if (is.null(attr ) &&
435
434
(! is.null(value ) && ! is.numeric(value ) && ! is.logical(value ))) {
436
- stop (" New value should be NULL, numeric or logical" )
435
+ cli :: cli_abort (" New value should be NULL, numeric or logical" )
437
436
}
438
437
if (is.null(attr ) && ! is.null(value ) && length(value ) != 1 ) {
439
- stop (" Logical or numeric value must be of length 1" )
438
+ cli :: cli_abort (" Logical or numeric value must be of length 1" )
440
439
}
441
440
if (! missing(from )) {
442
441
if ((! is.numeric(from ) && ! is.character(from )) || any(is.na(from ))) {
443
- stop( " ' from' must be a numeric or character vector without NAs" )
442
+ cli :: cli_abort( " {.arg from} must be a numeric or character vector without NAs" )
444
443
}
445
444
if ((! is.numeric(to ) && ! is.character(to )) || any(is.na(to ))) {
446
- stop( " 'to' must be a numeric or character vector without NAs" )
445
+ cli :: cli_abort( " {.arg to} must be a numeric or character vector without NAs" )
447
446
}
448
447
if (length(from ) != length(to )) {
449
- stop( " ' from' and 'to' must have the same length" )
448
+ cli :: cli_abort( " {.arg from} and {.arg to} must have the same length" )
450
449
}
451
450
}
452
451
@@ -498,7 +497,7 @@ expand.grid.unordered <- function(i, j, loops = FALSE, directed = FALSE) {
498
497
499
498
if (is.null(attr )) {
500
499
if (value > 1 ) {
501
- cli :: cli_abort(" value greater than one but graph is not weighted and no attribute was specified." )
500
+ cli :: cli_abort(" {.arg value} greater than one but graph is not weighted and {.arg attr} was not specified." )
502
501
}
503
502
x <- add_edges(x , toadd )
504
503
} else {
0 commit comments