[R] Shiny App inside R Package
Marc Girondot
marc_grt at yahoo.fr
Sun Sep 17 22:05:11 CEST 2017
I have this working in my package embryogrowth available in CRAN.
I have a function to call the shiny app:
web.tsd <- function() {
if (!requireNamespace("shiny", quietly = TRUE)) {
stop("shiny package is absent; Please install it first")
}
getFromNamespace("runApp", ns="shiny")(appDir = system.file("shiny",
package="embryogrowth"),
launch.browser =TRUE)
}
I have a folder inst and inside a folder shiny.
Within this folder inst/shiny/ I copy the two files server.R and ui.R
Marc
Le 17/09/2017 à 19:31, Axel Urbiz a écrit :
> Dear List,
>
> I have a wrapper function that creates a Shiny App, as illustrated below.
>
> I'd like to include the function myApp() inside a package. I'd appreciate
> your guidance here, as I could not find good instructions on this online.
>
>
> myApp <- function(x) {
> require(shiny)
> shinyApp(
> ui = fluidPage(
> sidebarLayout(
> sidebarPanel(sliderInput("n", "Bins", 5, 100, 20)),
> mainPanel(plotOutput("hist"))
> )
> ),
> server = function(input, output) {
> output$hist <- renderPlot(
> hist(x, breaks = input$n,
> col = "skyblue", border = "white")
> )
> }
> )
> }
>
> myApp(rnorm(100))
>
> Regards,
> Axel.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
.
More information about the R-help
mailing list