Skip to content

Commit 9c24c52

Browse files
authored
Merge pull request #132 from stan-dev/v2.2.1
Version 2.2.1
2 parents 41ca2b4 + cecb75c commit 9c24c52

23 files changed

+194
-215
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ r: devel
33
cache: packages
44

55
r_github_packages:
6+
- HenrikBengtsson/matrixStats@develop
67
- jimhester/covr
78

89
after_success:

DESCRIPTION

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: shinystan
22
Title: Interactive Visual and Numerical Diagnostics and Posterior Analysis for
33
Bayesian Models
4-
Version: 2.2.0
5-
Date: 2016-05-23
4+
Version: 2.2.1
5+
Date: 2016-08-31
66
Authors@R: c(person("Jonah", "Gabry", role = c("aut", "cre"),
77
email = "jsg2201@columbia.edu"),
88
person(family = "Stan Development Team", role = "ctb"),
@@ -36,7 +36,8 @@ Suggests:
3636
rstanarm (>= 2.9.0-3),
3737
testthat
3838
Imports:
39-
DT (>= 0.1),
39+
colourpicker,
40+
DT (>= 0.2),
4041
dygraphs (>= 0.4.5),
4142
ggplot2 (>= 2.1.0),
4243
gridExtra,
@@ -47,7 +48,7 @@ Imports:
4748
rsconnect (>= 0.4.2),
4849
rstan (>= 2.9.0-3),
4950
stats,
50-
shinyjs (>= 0.1.0),
51+
shinyjs (>= 0.6.0),
5152
shinythemes (>= 1.0.1),
5253
threejs (>= 0.2.1),
5354
utils,

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ import(threejs)
2222
import(utils)
2323
import(xts)
2424
importFrom(DT,datatable)
25+
importFrom(colourpicker,colourInput)
2526
importFrom(gridExtra,arrangeGrob)
2627
importFrom(gridExtra,grid.arrange)
2728
importFrom(gtools,mixedsort)
2829
importFrom(markdown,markdownToHTML)
2930
importFrom(reshape2,melt)
3031
importFrom(rsconnect,deployApp)
31-
importFrom(shinyjs,colourInput)
3232
importFrom(shinyjs,useShinyjs)
3333
importFrom(shinythemes,shinytheme)
3434
importFrom(stats,acf)

NEWS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
### Version 2.2.1
2+
* Better compatibility with latest releases of 'shinyjs' and 'DT' packages
3+
* `shinystan::launch_shinystan_demo()` now works without first having to load
4+
the package with a call to `library`
5+
* Unless running on a server, the app now stops running when browser tab is
6+
closed
7+
8+
### Version 2.2.0-1
9+
* Fix bug in `deploy_shinystan` preventing some ShinyStan apps from being
10+
deployed
11+
112
### Version 2.2.0
213
* Add optional argument `pars` to the `as.shinystan` method for stanfit objects,
314
allowing a subset of parameters to be selected for inclusion in the resulting

R/deploy_shinystan.R

Lines changed: 52 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2,85 +2,86 @@
22
# terms of the GNU General Public License as published by the Free Software
33
# Foundation; either version 3 of the License, or (at your option) any later
44
# version.
5-
#
5+
#
66
# shinystan is distributed in the hope that it will be useful, but WITHOUT ANY
77
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
88
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
9-
#
9+
#
1010
# You should have received a copy of the GNU General Public License along with
1111
# this program; if not, see <http://www.gnu.org/licenses/>.
1212

1313

1414
#' Deploy a ShinyStan app on the web using shinyapps.io by RStudio
15-
#'
16-
#' Requires a (free or paid) ShinyApps account. Visit
15+
#'
16+
#' Requires a (free or paid) ShinyApps account. Visit
1717
#' \url{http://www.shinyapps.io/} to sign up.
18-
#'
18+
#'
1919
#' @export
2020
#' @template args-sso
2121
#' @param appName The name to use for the application. Application names must be
2222
#' at least four characters long and may only contain letters, numbers, dashes
2323
#' and underscores.
24-
#' @param account shinyapps.io account username. Only required if more than one
24+
#' @param account shinyapps.io account username. Only required if more than one
2525
#' account is configured on the system.
2626
#' @param ... Optional arguments. See Details.
27-
#' @param deploy Should the app be deployed? The only reason for this to be
27+
#' @param deploy Should the app be deployed? The only reason for this to be
2828
#' \code{FALSE} is if you just want to check that the preprocessing before
2929
#' deployment is successful.
30-
#'
31-
#' @return \link[=invisible]{Invisibly}, \code{TRUE} if deployment succeeded
32-
#' (did not encounter an error) or, if \code{deploy} argument is set to
33-
#' \code{FALSE}, the path to the temporary directory containing the app ready
30+
#'
31+
#' @return \link[=invisible]{Invisibly}, \code{TRUE} if deployment succeeded
32+
#' (did not encounter an error) or, if \code{deploy} argument is set to
33+
#' \code{FALSE}, the path to the temporary directory containing the app ready
3434
#' for deployment (also invisibly).
35-
#'
36-
#' @details In \code{...}, the arguments \code{ppcheck_data} and
35+
#'
36+
#' @details In \code{...}, the arguments \code{ppcheck_data} and
3737
#' \code{ppcheck_yrep} can be specified. \code{ppcheck_data} should be a
3838
#' vector of observations to use for graphical posterior predictive checking
3939
#' and \code{ppcheck_yrep} should be a character string naming the parameter
4040
#' in \code{sso} containing the posterior predictive simulations/replications.
4141
#' The value of \code{ppcheck_yrep} is only used to preselect the appropriate
42-
#' parameter/generated quantity to use for the posterior predictive checking.
42+
#' parameter/generated quantity to use for the posterior predictive checking.
4343
#' \code{ppcheck_yrep} (but not \code{ppcheck_data}) can also be set
4444
#' interactively on shinyapps.io when using the app.
45-
#'
46-
#' @seealso The example in the \emph{Deploying to shinyapps.io} vignette that
45+
#'
46+
#' @seealso The example in the \emph{Deploying to shinyapps.io} vignette that
4747
#' comes with this package.
48-
#'
48+
#'
4949
#' \url{http://www.shinyapps.io/} to sign up for a free or paid ShinyApps
5050
#' account and for details on how to configure your account on your local
5151
#' system using RStudio's \pkg{\link[rsconnect]{rsconnect}} package.
52-
#'
52+
#'
5353
#' @examples
5454
#' \dontrun{
55-
#' # For this example assume sso is the name of the shinystan object for
56-
#' # the model you want to use. Assume also that you want to name your app
57-
#' # 'my-model' and that your shinyapps.io username is 'username'.
55+
#' # For this example assume sso is the name of the shinystan object for
56+
#' # the model you want to use. Assume also that you want to name your app
57+
#' # 'my-model' and that your shinyapps.io username is 'username'.
5858
#'
59-
#' deploy_shinystan(sso, appName = "my-model", account = "username")
59+
#' deploy_shinystan(sso, appName = "my-model", account = "username")
6060
#'
61-
#' # If you only have one ShinyApps account configured then you can also omit
62-
#' # the 'account' argument.
61+
#' # If you only have one ShinyApps account configured then you can also omit
62+
#' # the 'account' argument.
6363
#'
6464
#' deploy_shinystan(sso, appName = "my-model")
6565
#' }
66-
#'
66+
#'
6767
#' @importFrom rsconnect deployApp
68-
#'
68+
#'
6969
deploy_shinystan <- function(sso, appName, account = NULL, ..., deploy = TRUE) {
7070
sso_check(sso)
7171
if (missing(appName))
7272
stop("'appName' is required.")
73-
73+
7474
# copy contents to temporary directory and write necessary additional lines to
7575
# ui, server, and global
7676
appDir <- tempdir()
7777
deployDir <- file.path(appDir, "ShinyStan")
7878
contents <- system.file("ShinyStan", package = "shinystan")
7979
file.copy(from = contents, to = appDir, recursive = TRUE)
80-
80+
8181
server_pkgs <- c(
8282
"shiny",
8383
"shinyjs",
84+
"colourpicker",
8485
"markdown",
8586
"shinythemes"
8687
)
@@ -99,25 +100,22 @@ deploy_shinystan <- function(sso, appName, account = NULL, ..., deploy = TRUE) {
99100
server_lines <- paste0("library(", server_pkgs, ");")
100101
ui_lines <- paste0("library(", ui_pkgs, ");")
101102
global_lines <- paste(
102-
"load('sso.RData');",
103+
"load('sso.RData');",
103104
"if (file.exists('y.RData')) load('y.RData')"
104105
)
105106
for (ff in c("ui", "server", "global")) {
106107
file_name <- file.path(deployDir, paste0(ff, ".R"))
107108
fconn <- file(file_name, 'r+')
108109
original_content <- readLines(fconn)
109-
if (ff %in% c("ui", "server")) {
110-
sel <- grep(".SHINYSTAN_OBJECT", original_content)
111-
original_content <- original_content[-sel]
112-
}
113110
new_lines <- get(paste0(ff, "_lines"))
114111
writeLines(c(new_lines, original_content), con = fconn)
115112
close(fconn)
116113
}
117-
114+
118115
# save sso to deployDir
119-
object <- sso
120-
save(object, file = file.path(deployDir, "sso.RData"))
116+
.SHINYSTAN_OBJECT <- sso
117+
save(.SHINYSTAN_OBJECT, file = file.path(deployDir, "sso.RData"))
118+
121119
# save ppcheck_data and set ppcheck defaults
122120
pp <- list(...)
123121
if ("ppcheck_data" %in% names(pp)) {
@@ -130,10 +128,10 @@ deploy_shinystan <- function(sso, appName, account = NULL, ..., deploy = TRUE) {
130128
y_name = "y"
131129
)
132130
}
133-
131+
134132
if (!deploy)
135133
return(invisible(deployDir))
136-
134+
137135
rsconnect::deployApp(
138136
appDir = deployDir,
139137
appName = appName,
@@ -144,24 +142,17 @@ deploy_shinystan <- function(sso, appName, account = NULL, ..., deploy = TRUE) {
144142

145143

146144

147-
# functions to set defaults for ppcheck shiny::selectInput for y and y_rep
145+
# functions to set defaults for ppcheck shiny::selectInput for y and y_rep
148146
set_ppcheck_defaults <- function(appDir, yrep_name, y_name = "y") {
149-
stopifnot(is.character(yrep_name), is.character(y_name),
147+
stopifnot(is.character(yrep_name), is.character(y_name),
150148
length(yrep_name) == 1, length(y_name) == 1)
151149
fileDir <- file.path(appDir, "server_files", "pages", "diagnose", "ppcheck", "ui")
152-
y_file <- file.path(fileDir, "pp_y_from_r.R")
153-
yrep_file <- file.path(fileDir, "pp_yrep_from_sso.R")
154-
for (file in c("y_file", "yrep_file")) {
155-
f <- get(file)
156-
if (file.exists(f)) {
157-
file.remove(f)
158-
file.create(f)
159-
}
150+
ppc_file <- file.path(fileDir, "pp_get_y_and_yrep.R")
151+
if (file.exists(ppc_file)) {
152+
file.remove(ppc_file)
153+
file.create(ppc_file)
160154
}
161-
.write_files(
162-
files = c(y_file, yrep_file),
163-
lines = c(.y_lines(y_name), .yrep_lines(yrep_name))
164-
)
155+
.write_files(files = ppc_file, lines = .ppc_lines(y_name, yrep_name))
165156
}
166157

167158
.write_files <- function(files, lines) {
@@ -173,25 +164,22 @@ set_ppcheck_defaults <- function(appDir, yrep_name, y_name = "y") {
173164
}
174165
}
175166

176-
.y_lines <- function(y_name = "y") {
167+
.ppc_lines <- function(y_name = "y", yrep_name) {
177168
paste0(
178-
"output$ui_pp_y_from_r <- renderUI({
169+
"output$ui_pp_get_y <- renderUI({
179170
choices <- objects(envir = .GlobalEnv)
180-
selectizeInput('y_name', label = span(style = 'color: #337ab7;', 'y, a vector of observations'),
181-
choices = c('', choices),
171+
selectizeInput('y_name', label = span(style = 'color: #337ab7;', 'y, a vector of observations'),
172+
choices = c('', choices),
182173
selected = '", y_name,"')
183-
})")
184-
}
174+
})
185175
186-
.yrep_lines <- function(yrep_name) {
187-
paste0(
188-
"output$ui_pp_yrep_from_sso <- renderUI({
189-
choices <- param_names
176+
output$ui_pp_get_yrep <- renderUI({
177+
choices <- PARAM_NAMES
190178
choices <- strsplit(choices, split = '[', fixed = TRUE)
191179
choices <- lapply(choices, function(i) return(i[1]))
192180
choices <- unique(unlist(choices))
193-
selectizeInput('yrep_name',
194-
label = span(style = 'color: #337ab7;', 'y_rep, posterior predictive replications'),
181+
selectizeInput('yrep_name',
182+
label = span(style = 'color: #337ab7;', 'y_rep, posterior predictive replications'),
195183
choices = c('', choices),
196184
selected = '", yrep_name,"')
197185
})"

R/launch_shinystan.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ launch_shinystan_demo <- function(demo_name = "eight_schools",
123123
rstudio = getOption("shinystan.rstudio"),
124124
...) {
125125
demo_name <- match.arg(demo_name)
126-
demo_object <- get(demo_name)
127-
invisible(launch(demo_object, rstudio = rstudio, ...))
126+
data(list = demo_name, package = "shinystan", envir = environment())
127+
invisible(launch(get(demo_name, inherits = FALSE), rstudio = rstudio, ...))
128128
}
129129

130130
# Internal launch function

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy