Skip to content

Commit 71cf411

Browse files
committed
reformat simulation summary
1 parent cfbad06 commit 71cf411

3 files changed

Lines changed: 71 additions & 14 deletions

File tree

server.R

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ assign('input_termslist', list(),
141141
#'
142142
#' Notice that already in this chunk of code we call previously declared reactive
143143
#' objects. For example, to use the reactive list of vertex attributes in the
144-
#' definition of the numeric vertex attributes, we call `attr()`.
144+
#' definition of the numeric vertex attributes, we call `attrib()`.
145145
#+ eval=FALSE
146146

147147
#move to Data panel when user clicks Get Started button
@@ -563,7 +563,7 @@ nwattrinit <- reactive({
563563
})
564564

565565
#list of all vertex attributes in nw (after adding new)
566-
attr <- reactive({
566+
attrib <- reactive({
567567
attr <- c()
568568
if(is.network(nw())){
569569
attr<-list.vertex.attributes(nw())
@@ -573,7 +573,7 @@ attr <- reactive({
573573

574574
#don't allow "na" or "vertex.names" as vertex attributes in menus on fit tab
575575
menuattr <- reactive({
576-
menuattr <- attr()
576+
menuattr <- attrib()
577577
if(is.element("na",menuattr)){
578578
menuattr <- menuattr[-which("na"==menuattr)]
579579
}
@@ -587,9 +587,9 @@ menuattr <- reactive({
587587
numattr <- reactive({
588588
numattr <- c()
589589
if(is.network(nw())){
590-
for(i in 1:length(attr())){
591-
if(is.numeric(get.vertex.attribute(nw(),attr()[i]))){
592-
numattr <- append(numattr,attr()[i])
590+
for(i in 1:length(attrib())){
591+
if(is.numeric(get.vertex.attribute(nw(),attrib()[i]))){
592+
numattr <- append(numattr,attrib()[i])
593593
}
594594
}}
595595
numattr})
@@ -964,7 +964,7 @@ output$attr2 <- renderPrint({
964964
output$dynamiccolor <- renderUI({
965965
selectInput('colorby',
966966
label = 'Color nodes according to:',
967-
c('None' = 2, attr()),
967+
c('None' = 2, attrib()),
968968
selectize = FALSE)
969969
})
970970
outputOptions(output,'dynamiccolor',suspendWhenHidden=FALSE, priority=10)
@@ -2438,21 +2438,54 @@ output$currentdataset4 <- renderPrint({
24382438
})
24392439

24402440

2441-
output$sim.summary <- renderPrint({
2441+
output$simsummary <- renderPrint({
24422442
if (input$simButton == 0){
24432443
return(cat(''))
24442444
}
2445-
model1sim <- isolate(model1simreac())
2446-
if (isolate(input$nsims) == 1){
2447-
return(model1sim)
2445+
sim <- isolate(model1simreac())
2446+
n <- isolate(input$nsims)
2447+
sum <- list()
2448+
sum[1] <- "\n"
2449+
sum[2] <- paste("Number of Networks: ",n, "\n")
2450+
sum[3] <- paste("Model: ", nwname(),' ~ ',ergm.terms(), "\n")
2451+
sum[4] <- paste("Reference: ", format(attr(sim,'reference')), "\n")
2452+
sum[5] <- paste("Constraints: ", format(attr(sim, 'constraints')), "\n")
2453+
sum[6] <- paste("Parameters: \n")
2454+
cat(unlist(sum))
2455+
})
2456+
2457+
output$simcoef <- renderPrint({
2458+
if (input$simButton == 0){
2459+
return(cat(''))
2460+
}
2461+
sim <- isolate(model1simreac())
2462+
c <- attr(sim, 'coef')
2463+
c <- cbind(format(names(c)),c)
2464+
write.table(c, quote=FALSE, row.names=FALSE, col.names=FALSE)
2465+
})
2466+
2467+
output$simstats <- renderPrint({
2468+
if (input$simButton == 0){
2469+
return(cat(''))
2470+
}
2471+
sim <- isolate(model1simreac())
2472+
m <- format(t(attr(sim,'stats')))
2473+
m <- cbind(format(rownames(m)),m)
2474+
write.table(m, quote=F, row.names=F, col.names=F)
2475+
})
2476+
2477+
output$simsummary2 <- renderPrint({
2478+
if (input$simButton == 0){
2479+
return(cat(''))
24482480
}
2449-
return(summary(model1sim))
2481+
sim <- isolate(model1simreac())
2482+
sim
24502483
})
24512484

24522485
output$dynamiccolor2 <- renderUI({
24532486
selectInput('colorby2',
24542487
label = 'Color nodes according to:',
2455-
c('None' = 2, attr()),
2488+
c('None' = 2, attrib()),
24562489
selected = 2,
24572490
selectize = FALSE)
24582491
})

ui.R

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,20 @@ url = {http://statnetproject.org}
996996
label = 'Download Plot'))
997997
),
998998
tabPanel('Simulation Summary',
999-
verbatimTextOutput('sim.summary'))
999+
conditionalPanel(condition="input.nsims > 1",
1000+
wellPanel(
1001+
verbatimTextOutput('simsummary'),
1002+
verbatimTextOutput('simcoef'),
1003+
p('Stored network statistics:',
1004+
style='font-family:monospace; margin:0 0 0 2px; font-size:13px;'),
1005+
verbatimTextOutput('simstats')
1006+
)
1007+
),
1008+
conditionalPanel(condition="input.nsims == 1",
1009+
verbatimTextOutput('simsummary2')
1010+
)
1011+
1012+
)
10001013
)
10011014
)),
10021015
div(id='simtabhelp', class='helper-btn', icon('question-circle', 'fa-2x')),

www/style.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,14 @@ div.docpopup {
128128
background: #FFFFFF;
129129
}
130130

131+
#simsummary {
132+
border-style: none;
133+
padding: 0px;
134+
margin: 0px
135+
}
136+
#simcoef,
137+
#simstats {
138+
border-style: none;
139+
padding: 5px;
140+
margin: 0 0 0 15px;
141+
}

0 commit comments

Comments
 (0)