Skip to content

Commit 712ab03

Browse files
committed
Copied simulate_simple() from statnet.common and dropped the required statnet.common version to 4.4.1.
1 parent ea959b6 commit 712ab03

4 files changed

Lines changed: 22 additions & 3 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Authors@R: c(
1414
person("Michał", " Bojanowski", role=c("ctb"), email="mbojanowski@kozminski.edu.pl"),
1515
person("Chad", "Klumb", role=c("ctb"), email="cklumb@gmail.com"))
1616
Depends: R (>= 2.10), utils
17-
Imports: tibble, magrittr, statnet.common (>= 4.5), stats
17+
Imports: tibble, magrittr, statnet.common (>= 4.4.1), stats
1818
Suggests:
1919
sna,
2020
testthat,

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ importFrom(graphics,strwidth)
188188
importFrom(graphics,text)
189189
importFrom(magrittr,"%>%")
190190
importFrom(magrittr,set_names)
191+
importFrom(statnet.common,EVL)
191192
importFrom(statnet.common,NVL)
192193
importFrom(statnet.common,once)
193-
importFrom(statnet.common,simplify_simple)
194194
importFrom(statnet.common,statnetStartupMessage)
195195
importFrom(stats,na.omit)
196196
importFrom(stats,rnorm)

R/coercion.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ as.matrix.network.edgelist<-function(x,attrname=NULL,as.sna.edgelist=FALSE,na.rm
260260
#
261261
#' @rdname as.matrix.network
262262
#' @param store.eid whether the edge ID should be stored in the third column (`.eid`).
263-
#' @importFrom statnet.common simplify_simple
264263
#' @export
265264
as_tibble.network<-function(x,attrnames=(match.arg(unit)=="vertices"),na.rm=TRUE,..., unit=c("edges", "vertices"), store.eid=FALSE){
266265
unit <- match.arg(unit)

R/misc.R

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,3 +568,23 @@ which.matrix.type<-function(x)
568568
}
569569
out
570570
}
571+
572+
573+
# This is a temporary transplant from statnet.common, copied here to ease transition on CRAN.
574+
#' @importFrom statnet.common EVL
575+
simplify_simple <- function(x, toNA = c("null","empty","keep"), empty = c("keep", "unlist"), ...){
576+
if(isFALSE(toNA)) toNA <- "keep"
577+
toNA <- match.arg(toNA)
578+
empty <- match.arg(empty)
579+
580+
if(is.atomic(x)) return(x)
581+
582+
x <- switch(toNA,
583+
keep = x,
584+
null = lapply(x, NVL, NA),
585+
empty = lapply(x, EVL, NA))
586+
587+
if(length(x)==0) switch(empty, keep=x, unlist=unlist(x, recursive=FALSE, ...))
588+
else if(all(lengths(x)==1L) && all(vapply(x, is.atomic, logical(1)))) unlist(x, recursive=FALSE, ...)
589+
else x
590+
}

0 commit comments

Comments
 (0)