Skip to content

Commit

Permalink
Closed #119 by adding node_quad_census()
Browse files Browse the repository at this point in the history
  • Loading branch information
jhollway committed Nov 5, 2021
1 parent b4f5b26 commit e3d9858
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Imports:
igraph,
magrittr,
network,
oaqc,
purrr,
RColorBrewer,
readxl,
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export(node_components)
export(node_constraint)
export(node_degree)
export(node_eigenvector)
export(node_quad_census)
export(node_smallworld)
export(node_tie_census)
export(node_triad_census)
Expand Down Expand Up @@ -240,6 +241,7 @@ importFrom(network,as.matrix.network.adjacency)
importFrom(network,as.matrix.network.incidence)
importFrom(network,as.network)
importFrom(network,is.network)
importFrom(oaqc,oaqc)
importFrom(purrr,map)
importFrom(readxl,read_xlsx)
importFrom(rlang,.data)
Expand Down
26 changes: 26 additions & 0 deletions R/census.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,32 @@ node_triad_census <- function(object){
out # This line says the function returns the output
}

#' @rdname census
#' @importFrom oaqc oaqc
#' @examples
#' (quad_cen <- node_quad_census(southern_women))
#' @export
node_quad_census <- function(object){
graph <- object %>% as_tidygraph() %>%
activate(edges) %>% as.data.frame()
out <- oaqc::oaqc(graph)[[1]]
out <- out[-1,]
rownames(out) <- node_names(object)
colnames(out) <- c("E4", # co-K4
"I41","I40", # co-diamond
"H4", # co-C4
"L42","L41","L40", # co-paw
"D42","D40", # co-claw
"U42","U41", # P4
"Y43","Y41", # claw
"P43","P42","P41", # paw
"04", # C4
"Z42","Z43", # diamond
"X4") # K4
if(is_twomode(object)) out <- out[,-c(8,9,14,15,16,18,19,20)]
out
}

#' @rdname census
#' @examples
#' group_tie_census(task_eg, cutree(cluster_structural_equivalence(task_eg), 4))
Expand Down
4 changes: 4 additions & 0 deletions man/census.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e3d9858

Please sign in to comment.