Skip to content

Commit

Permalink
name change
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
jgabry committed Aug 3, 2015
1 parent 995f983 commit ae702eb
Show file tree
Hide file tree
Showing 89 changed files with 560 additions and 576 deletions.
11 changes: 6 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: shinyStan
Package: shinystan
Title: Interactive Visual Summaries and Analysis for MCMC
Version: 2.0.0
Date: 2015-08-01
Date: 2015-08-03
Authors@R: c(person("Jonah", "Gabry", role = c("aut", "cre"),
email = "jsg2201@columbia.edu", comment = "Stan Development Team"),
person("Michael", "Andreae", role = "ctb"),
Expand All @@ -10,9 +10,10 @@ Authors@R: c(person("Jonah", "Gabry", role = c("aut", "cre"),
Maintainer: Jonah Gabry <jsg2201@columbia.edu>
Description: Immediate, informative, customizable visual and numerical summaries
of model parameters and convergence diagnostics for MCMC simulations.
shinyStan can be used to explore the output of MCMC programs written in
any programming language (and has additional features for Stan models).
Users can also deploy their own shinyStan apps online using
The ShinyStan app provided in the shinystan package can be used to explore
the output of MCMC programs written in any programming language
(and has additional features for Stan models).
Users can also deploy their own ShinyStan apps online using
RStudio's ShinyApps service. Note: to use this feature the user must install
the shinyapps package available from RStudio (Github url in
Additional_repositories).
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import(dygraphs)
import(ggplot2)
import(methods)
import(shiny)
import(shinyBS)
import(stats)
import(threejs)
import(xts)
Expand All @@ -25,6 +24,7 @@ importFrom(markdown,markdownToHTML)
importFrom(plyr,ddply)
importFrom(plyr,summarize)
importFrom(reshape2,melt)
importFrom(shinyBS,bsModal)
importFrom(shinyjs,colourInput)
importFrom(shinyjs,useShinyjs)
importFrom(xtable,print.xtable)
Expand Down
9 changes: 4 additions & 5 deletions R/array2shinystan.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
# This file is part of shinyStan
# Copyright (C) 2015 Jonah Sol Gabry & Stan Development Team
# This file is part of shinystan
# Copyright (C) Jonah Gabry
#
# shinyStan is free software; you can redistribute it and/or modify it under the
# shinystan is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# shinyStan is distributed in the hope that it will be useful, but WITHOUT ANY
# shinystan is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses/>.


# Convert 3D array to shinystan object
#
# @param X A 3D array of posterior simulations with dimensions corresponding to
Expand Down
21 changes: 12 additions & 9 deletions R/as.shinystan.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# This file is part of shinyStan
# Copyright (C) 2015 Jonah Sol Gabry & Stan Development Team
# This file is part of shinystan
# Copyright (C) Jonah Gabry
#
# shinyStan is free software; you can redistribute it and/or modify it under the
# shinystan is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# shinyStan is distributed in the hope that it will be useful, but WITHOUT ANY
# shinystan is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
Expand All @@ -30,7 +30,7 @@
#' @param Y An object to test.
#' @param ... Additional arguments. See \strong{Details}, below, for instructions.
#' @return For \code{as.shinystan} an object of class \code{shinystan} that can
#' be used with \code{\link[shinyStan]{launch_shinystan}}. For
#' be used with \code{{launch_shinystan}}. For
#' \code{is.shinystan} a logical value indicating whether the tested object
#' is a \code{shinystan} object.
#' @details If \code{X} is a \code{stanfit} object then no additional arguments
Expand All @@ -45,11 +45,11 @@
#' For scalar parameters use \code{0} as the dimension. See \strong{Examples}.}
#' \item{\code{model_code}}{A character string with the code you used to run your model.
#' This can also be added to your \code{shinystan} object later using the
#' \code{\link[shinyStan]{include_model_code}} function. See \code{\link[shinyStan]{include_model_code}}
#' \code{\link{include_model_code}} function. See \code{\link{include_model_code}}
#' for additional formatting instructions. After launching the app \code{model_code}
#' will be viewable in the \strong{Model Code} tab.}
#' }
#' @seealso \code{\link[shinyStan]{launch_shinystan}}, \code{\link[shinyStan]{launch_shinystan_demo}}
#' @seealso \code{\link{launch_shinystan}}, \code{\link{launch_shinystan_demo}}
#' @export
#'
#' @examples
Expand Down Expand Up @@ -96,15 +96,18 @@ as.shinystan <- function(X, ...) {
if (what_X_is == "shinystan") {
message(
paste0(Xname, " is already a shinystan object.\n",
"You can use launch_shinystan(", Xname, ") to launch shinyStan.")
"You can use launch_shinystan(", Xname,
") to launch ShinyStan.")
)
return(X)
}
if (what_X_is == "stanfit") return(stan2shinystan(X, ...))
if (what_X_is == "mcmclist") return(mcmc2shinystan(X, ...))
if (what_X_is == "chainlist") return(chains2shinystan(X, ...))
if (what_X_is == "other") {
if (!is.array(X)) stop(paste(Xname, "is not a valid input type. See ?as.shinystan"), call. = FALSE)
if (!is.array(X))
stop(paste(Xname, "is not a valid input type. See ?as.shinystan"),
call. = FALSE)
array2shinystan(X, ...)
}

Expand Down
8 changes: 4 additions & 4 deletions R/chains2shinystan.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# This file is part of shinyStan
# Copyright (C) 2015 Jonah Sol Gabry & Stan Development Team
# This file is part of shinystan
# Copyright (C) Jonah Gabry
#
# shinyStan is free software; you can redistribute it and/or modify it under the
# shinystan is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# shinyStan is distributed in the hope that it will be useful, but WITHOUT ANY
# shinystan is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
Expand Down
9 changes: 4 additions & 5 deletions R/convenience.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# This file is part of shinyStan
# Copyright (C) 2015 Jonah Sol Gabry & Stan Development Team
# This file is part of shinystan
# Copyright (C) Jonah Gabry
#
# shinyStan is free software; you can redistribute it and/or modify it under the
# shinystan is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# shinyStan is distributed in the hope that it will be useful, but WITHOUT ANY
# shinystan is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses/>.


retrieve_rhat <- function(sso, pars) {
if (missing(pars)) {
Expand Down
16 changes: 8 additions & 8 deletions R/deploy_shinystan.R
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# This file is part of shinyStan
# Copyright (C) 2015 Jonah Sol Gabry & Stan Development Team
# This file is part of shinystan
# Copyright (C) Jonah Gabry
#
# shinyStan is free software; you can redistribute it and/or modify it under the
# shinystan is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# shinyStan is distributed in the hope that it will be useful, but WITHOUT ANY
# shinystan is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses/>.


#' Deploy to shinyapps.io
#' Deploy a ShinyStan app to shinyapps.io
#'
#' Requires a (free or paid) ShinyApps account. Visit
#' \url{http://www.shinyapps.io/} to sign up. Also requires the \pkg{shinyapps}
Expand Down Expand Up @@ -63,7 +63,7 @@
deploy_shinystan <- function(sso, appName, account = NULL, ...) {
sso_check(sso)
if (!requireNamespace("shinyapps", quietly = TRUE))
stop("Deploying a shinyStan app requires the shinyapps package.",
stop("Deploying a ShinyStan app requires the shinyapps package.",
"\nTo install use devtools::install_github('rstudio/shinyapps')",
call. = FALSE)
if (missing(appName))
Expand All @@ -73,8 +73,8 @@ deploy_shinystan <- function(sso, appName, account = NULL, ...) {
# copy contents to temporary directory and write necessary additional lines to
# ui, server, and global
appDir <- tempdir()
deployDir <- file.path(appDir, "shinyStan")
contents <- system.file("shinyStan", package = "shinyStan")
deployDir <- file.path(appDir, "shinystan")
contents <- system.file("shinystan", package = "shinystan")
file.copy(from = contents, to = appDir, recursive = TRUE)
server_pkgs <- c("shiny", "shinyBS", "shinyjs", "markdown")
ui_pkgs <- c(server_pkgs, "ggplot2", "gtools", "plyr", "reshape2",
Expand Down
14 changes: 7 additions & 7 deletions R/eight_schools.R
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# This file is part of shinyStan
# Copyright (C) 2015 Jonah Sol Gabry & Stan Development Team
# This file is part of shinystan
# Copyright (C) Jonah Gabry
#
# shinyStan is free software; you can redistribute it and/or modify it under the
# shinystan is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# shinyStan is distributed in the hope that it will be useful, but WITHOUT ANY
# shinystan is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses/>.

#' shinyStan demo: Eight Schools
#' ShinyStan demo: Eight Schools
#'
#' A shinyStan object for the Stan "Eight Schools" demo model
#'
#' A shinystan object for the Stan "Eight Schools" demo model
#' @seealso \code{\link{launch_shinystan_demo}}
#' @format An S4 object of class \code{shinystan}
"eight_schools"
10 changes: 5 additions & 5 deletions R/generate_quantity.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# This file is part of shinyStan
# Copyright (C) 2015 Jonah Sol Gabry & Stan Development Team
# This file is part of shinystan
# Copyright (C) Jonah Gabry
#
# shinyStan is free software; you can redistribute it and/or modify it under the
# shinystan is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# shinyStan is distributed in the hope that it will be useful, but WITHOUT ANY
# shinystan is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
Expand All @@ -24,7 +24,7 @@
#' @param param2 Optional. Name of second paramter as character string.
#' @param new_name Name for the new parameter as character string.
#' @return A \code{shinystan} object with \code{new_name} included as a parameter.
#' @seealso \code{\link[shinyStan]{as.shinystan}}, \code{\link[shinyStan]{launch_shinystan_demo}}
#' @seealso \code{\link{as.shinystan}}, \code{\link{launch_shinystan_demo}}
#' @export
#'
#' @examples
Expand Down
27 changes: 14 additions & 13 deletions R/include_model_code.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# This file is part of shinyStan
# Copyright (C) 2015 Jonah Sol Gabry & Stan Development Team
# This file is part of shinystan
# Copyright (C) Jonah Gabry
#
# shinyStan is free software; you can redistribute it and/or modify it under the
# shinystan is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# shinyStan is distributed in the hope that it will be useful, but WITHOUT ANY
# shinystan is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
Expand All @@ -17,15 +17,16 @@
#' Add model code to a \code{shinystan} object
#'
#' @param sso A \code{shinystan} object.
#' @param code The code you want to add. See \strong{Details} below for
#' formatting instructions.
#' @return The \code{shinystan} object \code{sso} with \code{code} in the
#' \code{model_code} slot.
#'
#' @details \code{code} should be a character string that can be used as an argument
#' to \code{cat}. See \strong{Examples}, below.
#' @note This is intended for users who did not run their models using \pkg{rstan}.
#' For \pkg{rstan} users the model code will be automatically available.
#' @param code The code you want to add. See \strong{Details} below for
#' formatting instructions.
#' @return The \code{shinystan} object \code{sso} with \code{code} in the
#' \code{model_code} slot.
#'
#' @details \code{code} should be a character string that can be used as an
#' argument to \code{cat}. See \strong{Examples}, below.
#' @note This is intended for users who did not run their models using
#' \pkg{rstan}. For \pkg{rstan} users the model code will be automatically
#' available.
#'
#' @seealso \code{cat}
#' @export
Expand Down
51 changes: 22 additions & 29 deletions R/launch_shinystan.R
Original file line number Diff line number Diff line change
@@ -1,41 +1,32 @@
# This file is part of shinyStan
# Copyright (C) 2015 Jonah Sol Gabry & Stan Development Team
# This file is part of shinystan
# Copyright (C) Jonah Gabry
#
# shinyStan is free software; you can redistribute it and/or modify it under the
# shinystan is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# shinyStan is distributed in the hope that it will be useful, but WITHOUT ANY
# shinystan is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses/>.


#' Launch shinyStan app
#' ShinyStan app
#'
#' @export
#'
#' @param object An object of class \code{shinystan} or \code{stanfit}. See
#' \code{\link[shinyStan]{as.shinystan}} for converting to a
#' \code{shinystan} object (sso).
#' @param ... Optional arguments to pass to \code{\link[shiny]{runApp}}. See
#' Details (RStudio users in particular).
#' @param object An object of class \code{shinystan}, \code{stanfit}, or
#' \code{stanreg}. See \code{\link{as.shinystan}} for converting other
#' objects to a \code{shinystan} object (sso).
#' @param rstudio For RStudio users, should the app launch in RStudio's Viewer?
#' The default (FALSE) is to launch the app in the default web browser.
#' @param ... Optional arguments to pass to \code{\link[shiny]{runApp}}.
#' @return An S4 object of class \code{shinystan}.
#'
#' @details Unless you are using RStudio, \code{launch_shinystan} will open the
#' app in your system's default web browser. For RStudio users
#' \strong{shinyStan} will launch in RStudio's (pop-up) Viewer pane by
#' default. If you prefer to use \strong{shinyStan} in your web browser (or if
#' you are having trouble with the RStudio Viewer pane) you can
#' specify \code{launch.browser = TRUE} in \code{...}. Alternatively, if
#' \strong{shinyStan} is open in the RStudio Viewer pane you can click on
#' 'Open in Browser' (at the top left of the Viewer pane).
#'
#' @seealso \code{\link[shinyStan]{as.shinystan}},
#' \code{\link[shinyStan]{launch_shinystan_demo}}
#' @seealso \code{\link{as.shinystan}},
#' \code{\link{launch_shinystan_demo}}
#' @examples
#' \dontrun{
#' # If X is a stanfit object (or shinystan object (sso))
Expand All @@ -45,18 +36,20 @@
#' X_sso <- launch_shinystan(as.shinystan(X, model_name = "Example"))
#' }
#'
launch_shinystan <- function(object, launch.browser = TRUE, ...) {
launch_shinystan <- function(object, rstudio = FALSE, ...) {
name <- deparse(substitute(object))
no_name <- substr(name, 1, 12) == "as.shinystan"
if (missing(object))
stop("Please specify a shinystan or stanfit object.")

if (!is.shinystan(object) && !inherits(object, "stanreg")
&& !inherits(object, "stanfit"))
stop(paste(name, "is not a shinystan or stanfit object."))
if (inherits(object, "stanreg"))
object <- object$stanfit
if (inherits(object, "stanfit"))
object <- stan2shinystan(object)
if (!is.shinystan(object))
stop(paste(name, "is not a valid input. See ?launch_shinystan"))
message(paste("\n Loading... \n",
"For large models shinyStan may take a few moments to launch."))
"For large models ShinyStan may take a few moments to launch."))
on.exit(cleanup_shinystan())
launch(object, launch.browser, ...)
launch(object, rstudio, ...)
invisible(return_sso())
}
Loading

0 comments on commit ae702eb

Please sign in to comment.