@@ -130,30 +130,27 @@ c.network.list <- function(..., check_attr = TRUE) {
130130 dots <- list (... )
131131
132132 # Merge network lists without attributes
133- lapply(dots , function (x ) {
134- attributes(x ) <- NULL
135- x
136- }) - > l_networks
137- rval <- do.call(" c" , l_networks )
133+ rval <- do.call(" c" , map(dots , unclass ))
138134
139135 # Check attributes
140- if (check_attr ) {
136+ if (check_attr ) {
141137 # Names of attributes to check with `all.equal()`
142138 attr_names <- c(" coefficients" , " control" , " response" ,
143139 " formula" , " constraints" , " reference" )
144- for (an in attr_names ) {
140+ for (an in attr_names ) {
145141 al <- map(dots , ~ attr(.x , an ))
146142 ok <- all_identical(al , all.equal )
147- if (! ok ) stop(paste0( " network lists do not have equal values on attribute " , an ) )
143+ if (! ok ) stop(" network lists do not have equal values on attribute " , an )
148144 }
149145
150146 # Check if "stats" have identical columns
151147 l_stats <- map(dots , ~ attr(.x , " stats" ))
152148 ok <- all_identical(
153- lapply (l_stats , function (x ) colnames(x )),
149+ map (l_stats , function (x ) colnames(x )),
154150 .p = identical
155151 )
156- if (! ok ) stop(" network lists do not have identical columns of 'stats' attribute" )
152+ if (! ok ) stop(" network lists do not have identical columns of " ,
153+ sQuote(" stats" ), " attribute" )
157154 }
158155 # Return the list of networks with attributes merged or taken from the
159156 # first object
0 commit comments