@@ -18,25 +18,28 @@ save_and_close_button <- function() {
1818shinystan_version <- function () {
1919 # prevents error when deployed to shinyapps.io
2020 ver <- try(utils :: packageVersion(" shinystan" ))
21- if (inherits(ver , " try-error" ))
21+ if (inherits(ver , " try-error" )) {
2222 return ()
23- else
23+ } else {
2424 strong(paste(" Version" , ver ))
25+ }
2526}
2627
2728logo_and_name <- function () {
28- div(div(
29- img(
30- src = " wide_ensemble.png" ,
31- class = " wide-ensemble" ,
32- width = " 100%"
33- )
34- ),
3529 div(
36- style = " margin-top: 25px" ,
37- img(src = " stan_logo.png" , class = " stan-logo" ),
38- div(id = " shinystan-title" , " ShinyStan" )
39- ))
30+ div(
31+ img(
32+ src = " wide_ensemble.png" ,
33+ class = " wide-ensemble" ,
34+ width = " 100%"
35+ )
36+ ),
37+ div(
38+ style = " margin-top: 25px" ,
39+ img(src = " stan_logo.svg" , class = " stan-logo" ),
40+ div(id = " shinystan-title" , " ShinyStan" )
41+ )
42+ )
4043}
4144
4245
@@ -56,60 +59,82 @@ save_and_close_reminder <- function(id) {
5659
5760# show/hide options/glossary ---------------------------------------------
5861a_options <- function (name ) {
59- lab <- if (name == " table" )
60- " Table Options" else " Show/Hide Options"
61- div(class = " aoptions" ,
62- checkboxInput(
63- inputId = paste0(name , " _options_show" ),
64- label = strong(style = " margin-top: 20px; color: #222222;" , lab ),
65- value = FALSE
66- ))
62+ lab <- if (name == " table" ) {
63+ " Table Options"
64+ } else {
65+ " Show/Hide Options"
66+ }
67+ div(
68+ class = " aoptions" ,
69+ checkboxInput(
70+ inputId = paste0(name , " _options_show" ),
71+ label = strong(style = " margin-top: 20px; color: #222222;" , lab ),
72+ value = FALSE
73+ )
74+ )
6775}
6876a_glossary <- function (id ) {
69- div(class = " aoptions" ,
70- actionLink(
71- inputId = id ,
72- label = strong(style = " margin-top: 20px; color: #222222;" , " Glossary" ),
73- icon = icon(" book" , lib = " glyphicon" )
74- ))
77+ div(
78+ class = " aoptions" ,
79+ actionLink(
80+ inputId = id ,
81+ label = strong(style = " margin-top: 20px; color: #222222;" , " Glossary" ),
82+ icon = icon(" book" , lib = " glyphicon" )
83+ )
84+ )
7585}
7686
7787
78-
7988# plotOutput generators ---------------------------------------------------
80- dygraphOutput_175px <- function (id )
89+ dygraphOutput_175px <- function (id ) {
8190 dygraphs :: dygraphOutput(id , height = " 175px" )
82- plotOutput_200px <- function (id , ... )
91+ }
92+ plotOutput_200px <- function (id , ... ) {
8393 plotOutput(id , height = " 200px" )
84- plotOutput_400px <- function (id , ... )
94+ }
95+ plotOutput_400px <- function (id , ... ) {
8596 plotOutput(id , height = " 400px" )
86-
97+ }
8798
8899
89100# conditionalPanel generator for EXPLORE/density -------------------------
90101condPanel_dens_together <- function (... ) {
91102 conditionalPanel(condition = " input.dens_chain_split == 'Together'" , ... )
92103}
93104condPanel_dens_prior <- function (dist , ... ) {
94- cond <- paste0(" input.dens_prior ==" ," '" , dist ," '" )
105+ cond <- paste0(" input.dens_prior ==" , " '" , dist , " '" )
95106 conditionalPanel(cond , ... )
96107}
97108
98109
99110# conditional transparency settings ---------------------------------------
100111alpha_calc_pt <- function (N ) {
101- if (N < = 100 ) return (1 )
102- else if (N < = 200 ) return (0.75 )
103- else if (N > = 1500 ) return (0.15 )
104- else 1 - pnorm(N / 1500 )
112+ if (N < = 100 ) {
113+ return (1 )
114+ } else if (N < = 200 ) {
115+ return (0.75 )
116+ } else if (N > = 1500 ) {
117+ return (0.15 )
118+ } else {
119+ 1 - pnorm(N / 1500 )
120+ }
105121}
106122
107123alpha_calc_lines <- function (N ) {
108- if (N < 50 ) return (0.5 )
109- if (N < 500 ) return (0.4 )
110- if (N < 1000 ) return (0.3 )
111- if (N < 5000 ) return (0.2 )
112- else return (0.1 )
124+ if (N < 50 ) {
125+ return (0.5 )
126+ }
127+ if (N < 500 ) {
128+ return (0.4 )
129+ }
130+ if (N < 1000 ) {
131+ return (0.3 )
132+ }
133+ if (N < 5000 ) {
134+ return (0.2 )
135+ } else {
136+ return (0.1 )
137+ }
113138}
114139
115140
@@ -125,28 +150,38 @@ transformation_selectInput <- function(id) {
125150
126151transform_helpText <- function (var = " x" ) {
127152 div(
128- if (var == " x" )
129- helpText(style = " font-size: 13px;" ,
130- " To apply a transformation" ,
131- " select a function and click" ,
132- code(" Transform" ))
133- else if (var == " x,y" )
134- helpText(style = " font-size: 13px;" ,
135- " To apply transformations" ,
136- " select a function for x and/or y" ,
137- " and click" , code(" Transform" ))
138- else
139- helpText(style = " font-size: 13px;" ,
140- " To apply transformations" ,
141- " select a function for x, y, and/or z" ,
142- " and click" , code(" Transform" ))
153+ if (var == " x" ) {
154+ helpText(
155+ style = " font-size: 13px;" ,
156+ " To apply a transformation" ,
157+ " select a function and click" ,
158+ code(" Transform" )
159+ )
160+ } else if (var == " x,y" ) {
161+ helpText(
162+ style = " font-size: 13px;" ,
163+ " To apply transformations" ,
164+ " select a function for x and/or y" ,
165+ " and click" ,
166+ code(" Transform" )
167+ )
168+ } else {
169+ helpText(
170+ style = " font-size: 13px;" ,
171+ " To apply transformations" ,
172+ " select a function for x, y, and/or z" ,
173+ " and click" ,
174+ code(" Transform" )
175+ )
176+ }
143177 )
144178}
145179
146180
147181# diagnostics help text ---------------------------------------------------
148- hT11 <- function (... )
182+ hT11 <- function (... ) {
149183 helpText(style = " font-size: 11px;" , ... )
184+ }
150185help_interval <- hT11(" Highlighted interval shows \\ (\\ bar{x} \\ pm sd(x)\\ )" )
151186help_lines <- hT11(" Lines are mean (solid) and median (dashed)" )
152187help_max_td <- hT11(" Horizontal line indicates the max_treedepth setting" )
@@ -162,7 +197,6 @@ help_dynamic <- hT11(
162197)
163198
164199
165-
166200# ppcheck plot descriptions ----------------------------------------------
167201plot_descriptions <-
168202 c(
@@ -175,7 +209,6 @@ plot_descriptions <-
175209 )
176210
177211
178-
179212# stan manual reference ---------------------------------------------------
180213stan_manual <- function () {
181214 helpText(
@@ -209,8 +242,10 @@ if (!exists(".SHINYSTAN_OBJECT")) {
209242 isTRUE(.SHINYSTAN_OBJECT @ misc $ stanreg ) &&
210243 ! is.null(.SHINYSTAN_OBJECT @ misc $ pp_check_plots )
211244
212- if (exists(" object" ))
245+ if (exists(" object" )) {
213246 rm(object )
214- if (exists(" .SHINYSTAN_OBJECT" ))
247+ }
248+ if (exists(" .SHINYSTAN_OBJECT" )) {
215249 rm(.SHINYSTAN_OBJECT )
250+ }
216251gc()
0 commit comments