@@ -293,7 +293,7 @@ metrics.hierarchy = function(network) {
293
293
294
294
295
295
# # The column headers for a centrality data frame calculated by the function \code{metrics.centrality}
296
- CENTRALITY_COLUMN_NAMES = c(" author. name" , " centrality" )
296
+ CENTRALITY_COLUMN_NAMES = c(" name" , " centrality" )
297
297
298
298
# ' Calculate the centrality value for authors from a network and project data.
299
299
# ' Only considers authors from the network that are also present in the project data and the
@@ -312,7 +312,10 @@ CENTRALITY_COLUMN_NAMES = c("author.name", "centrality")
312
312
# ' vector are to be classified. Authors that appear in the vector but are not
313
313
# ' part of the classification result (i.e., they are not present in the
314
314
# ' underlying data) will be added to it afterwards (with a centrality value of
315
- # ' \code{NA}). \code{NULL} means that no restriction is made. [default: NULL]
315
+ # ' \code{NA}). \code{NULL} means that the restriction is automatically
316
+ # ' calculated from the network's edge relations if and only if both network
317
+ # ' and data are present. In any other case \code{NULL} will not introduce any
318
+ # ' further restriction. [default: NULL]
316
319
# ' @return a data.frame with the columns \code{"author.name"} and \code{"centrality"} containing the centrality values
317
320
# ' for each respective author
318
321
metrics.centrality = function (network ,
@@ -323,7 +326,18 @@ metrics.centrality = function(network,
323
326
restrict.classification.to.authors = NULL ) {
324
327
type = match.arg(type )
325
328
326
- # # Calculate the centrality tables
329
+ # # check whether the restrict parameter is set to default (\code{NULL})
330
+ if (is.null(restrict.classification.to.authors )) {
331
+ # # now check whether both data and network are present
332
+ if (! is.null(network ) && ! is.null(proj.data )) {
333
+ # # in this case calculate the restrict parameter based on the edge relation
334
+ restrict.classification.to.authors = relations.to.authors(proj.data , network )
335
+ }
336
+ # # else leave the parameter at \code{NULL} which still serves as a default value for the
337
+ # # \code{get.auther.class.by.type} function
338
+ }
339
+
340
+ # # calculate the centrality tables
327
341
class = get.auther.class.by.type(network = network ,
328
342
proj.data = proj.data ,
329
343
type = type ,
@@ -335,5 +349,8 @@ metrics.centrality = function(network,
335
349
# # set column names accordingly
336
350
colnames(centrality ) = CENTRALITY_COLUMN_NAMES
337
351
352
+ # # order by centrality (desc) (with NA being at the bottom) and then by name (asc)
353
+ centrality = centrality [order(- centrality $ centrality , centrality $ name ), ]
354
+
338
355
return (centrality )
339
356
}
0 commit comments