Skip to content

Commit

Permalink
update ergmTerm search functions
Browse files Browse the repository at this point in the history
  • Loading branch information
martinamorris committed Jul 13, 2024
1 parent 2030103 commit 56931aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions inst/shiny/statnetWeb/global.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ inlineSelectInput <- function(inputId, label, choices, ...) {
}

# create a list of unique term names
splitargs <- function(searchterm, nw){
# allow searching by string -- set to NULL to get search by nw attributes
splitargs <- function(string, nw){
sink("NUL")
allterms <- search.ergmTerms(keyword = searchterm, net = nw)
allterms <- search.ergmTerms(search = string, net = nw)
sink()
ind1 <- regexpr(pattern = "\\(", allterms)
ind2 <- regexpr(pattern = "\\)", allterms)
termnames <- substr(allterms, start = rep(1, length(allterms)), stop = ind1 - 1)
termargs <- substr(allterms, start = ind1, stop = ind2)
dups <- duplicated(termnames)
termargs <- termargs[-which(dups)]
termnames <- unique(termnames)
termnames <- termnames[!dups]
termargs <- termargs[!dups]
list(names = termnames, args = termargs)
}



# disable widgets when they should not be usable
disableWidget <- function(id, session, disabled = TRUE) {
if (disabled) {
Expand Down
3 changes: 2 additions & 1 deletion inst/shiny/statnetWeb/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ histblue <- "#83B6E1"
tgray3 <- adjustcolor("gray", alpha.f = 0.3)
tgray7 <- adjustcolor("gray", alpha.f = 0.7)

allterms <- splitargs(searchterm = "")
# All ergm terms (no network or search terms passed)
allterms <- splitargs()

shinyServer(
function(input, output, session){
Expand Down

0 comments on commit 56931aa

Please sign in to comment.