@@ -34,16 +34,26 @@ inlineSelectInput <- function(inputId, label, choices, ...) {
3434 lapply(choices , tags $ option )))
3535}
3636
37- # create a list of unique term names
37+ # create a list of unique term names and arguments
3838# allow searching by string -- set to NULL to get search by nw attributes
39+ # note not all terms have arguments, so pattern matching accomodates
40+
3941splitargs <- function (string , nw ){
4042 sink(" NUL" )
4143 allterms <- search.ergmTerms(search = string , net = nw )
4244 sink()
45+
46+ hasarg <- ifelse(
47+ grepl(pattern = " [^ ]\\ (" , allterms ), 1 , 0 )
4348 ind1 <- regexpr(pattern = " \\ (" , allterms )
4449 ind2 <- regexpr(pattern = " \\ )" , allterms )
45- termnames <- substr(allterms , start = rep(1 , length(allterms )), stop = ind1 - 1 )
46- termargs <- substr(allterms , start = ind1 , stop = ind2 )
50+
51+ termnames <- substr(allterms ,
52+ start = rep(1 , length(allterms )),
53+ stop = ifelse(hasarg , ind1 - 1 , ind1 - 2 ))
54+ termargs <- ifelse(hasarg ,
55+ substr(allterms , start = ind1 , stop = ind2 ),
56+ " " )
4757 dups <- duplicated(termnames )
4858 termnames <- termnames [! dups ]
4959 termargs <- termargs [! dups ]
0 commit comments