Skip to content

Commit

Permalink
streamline splitargs function (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebey committed Jul 23, 2015
1 parent cdf9430 commit d1a3918
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
4 changes: 2 additions & 2 deletions inst/shiny/global.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ inlineSelectInput <- function(inputId, label, choices, ...) {
}

# create a list of unique term names
splitargs <- function(searchterm){
splitargs <- function(searchterm, nw){
sink("NUL")
allterms <- search.ergmTerms(searchterm)
allterms <- search.ergmTerms(keyword = searchterm, net = nw)
sink()
ind1 <- regexpr(pattern = "\\(", allterms)
ind2 <- regexpr(pattern = "\\)", allterms)
Expand Down
13 changes: 3 additions & 10 deletions inst/shiny/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ histblue <- "#83B6E1"
tgray3 <- adjustcolor("gray", alpha.f = 0.3)
tgray7 <- adjustcolor("gray", alpha.f = 0.7)

allterms <- splitargs("")
allterms <- splitargs(searchterm = "")

shinyServer(
function(input, output, session){
Expand Down Expand Up @@ -2779,15 +2779,8 @@ output$listofterms <- renderUI({
if(state$allterms){
current.terms <- allterms[[1]]
} else {
sink("NUL") # prevents terms from printing to console
matchterms <- search.ergmTerms(net=nw())
sink()
ind <- regexpr(pattern='\\(', matchterms)
for(i in 1:length(matchterms)){
matchterms[i] <- substr(matchterms[[i]], start=1, stop=ind[i]-1)
}
matchterms <- unique(matchterms)
current.terms <- unlist(matchterms)
matchterms <- splitargs(nw = nw())
current.terms <- matchterms[[1]]
}
selectizeInput('chooseterm', label = NULL,
choices = c("Select a term" = "", current.terms))
Expand Down

0 comments on commit d1a3918

Please sign in to comment.