I am new to shiny and the googleVis packages, and I am trying to construct to create a simple, bare bones gvisMotionChart in Shiny. I have been able to create the gvisMotionChart in a separate file, but when I try to run the Shiny app, it only displays the side bar panel and does not generate the animated chart.
ui.R
library(shiny)
library(googleVis)
shinyUI(fluidPage(
titlePanel("Google Motion Chart"),
sidebarLayout(
sidebarPanel("Inputs go Here"),
mainPanel(
htmlOutput("view")
)
)
))
server.R
library(shiny)
library(googleVis)
shinyServer(function(input, output) {
output$view <- renderGvis({
gvisMotionChart(Fruits,
idvar="Fruit",
timevar="Year")
})
})
One needs to enter:
shinyServer(function(input, output) { datasetInput <-
reactive({gvisMotionChart(Fruits, idvar="Fruit", timevar="Year") })
output$coolplot <- renderGvis ({ datasetInput() }) })
Related
My goal is to plot the output, a process map, onto the browser. The output plot continues to appear in the Viewer pane in RStudio.
All of the functionality works as expected and I'm able to call the appropriate data and generate a dynamic output based on the dropdown menu.
Any help would be much appreciated. Full code is below.
library(shiny)
library(bupaR)
library(pm4py)
library(reticulate)
library(processmapR)
ui <- fluidPage(
tags$h1("Process Mining"),
tags$p("The purpose of this application is to show the Process Map output"),
fluidRow(
selectInput("pm_type","Process Mining Type", c("absolute","relative"))),
fluidRow(
plotOutput("plot1"))
)
server <- function(input, output) {
selectedData <- reactive({input$pm_type})
output$plot1 <- renderPlot({
patients %>%
process_map(type = frequency(selectedData()))
})
}
shinyApp(ui = ui, server = server)
To get output of process_map in shiny you have to use GrViz functions from DiagrammeR.
library(shiny)
library(bupaR)
library(pm4py)
library(reticulate)
library(processmapR)
library(DiagrammeR)
ui <- fluidPage(
tags$h1("Process Mining"),
tags$p("The purpose of this application is to show the Process Map output"),
fluidRow(
selectInput("pm_type","Process Mining Type", c("absolute","relative"))),
fluidRow(
grVizOutput("plot1"))
)
server <- function(input, output) {
selectedData <- reactive({input$pm_type})
output$plot1 <- renderGrViz({
patients %>%
process_map(type = frequency(selectedData()))
})
}
shinyApp(ui = ui, server = server)
I want to display a flow chart in shiny, it just not showing in shiny browsers, but displays in the viewer pane in rstudio.
library(shiny)
library(DiagrammeR)
ui <- fluidPage(
plotOutput(outputId ="temp")
)
server <- function(input, output, session) {
plotInput = function(){
DiagrammeR(paste('graph LR',
sprintf("A(%s)-->B", iris[1,1]),
sep = ';'))
}
output$temp<-renderPlot(
plotInput()
)
}
shinyApp(ui, server)
I am having issues getting a map using tmap to load in shiny. When I run the shiny code, the input sections show up, but not the output. The code doesn't crash, but it also never finishes running. My goal is to be able to have an interactive map using tmap and leaflet, which has been able to run outside of shiny.
library(tmap) # and maybe also: library(tmaptools)
library(shiny)
ui <- fluidPage(
titlePanel("Europe"),
mainPanel(
plotOutput(outputId = "europe")))
server <- function(input, output) {
output$europe <- renderPlot({
qtm(Europe)})}
shinyApp(ui, server)
All works for me:
library(shiny)
library(tmap)
data("Europe")
ui <- fluidPage(
titlePanel("Europe"),
mainPanel(
plotOutput(outputId = "europe")))
server <- function(input, output) {
output$europe <- renderPlot({
qtm(Europe)
})
}
shinyApp(ui, server)
I am trying to build shiny dashboard application.
Within the application, I need to render a table dynamically.
When I load the application, I am not receiving the tabular output.
I have split the code into three files: global.R, ui.R, and server.R
global.R
my_data <- head(mtcars)
ui.R
tabItem(tabName = "impRels",
fluidRow(
box(DT::dataTableOutput("table1"))
)
)
server.R
output$table1 <- DT::renderDataTable({
datatable(my_data)
})
Simplified, as a start. You might want to work on your UI, though.
library(shiny)
library(DT)
my_data <- head(mtcars)
ui <- shinyUI(
fluidPage(
fluidRow( dataTableOutput("table1") )
)
)
server <- shinyServer(function(input, output, session){
output$table1 <- renderDataTable({ datatable(my_data) })
})
shinyApp(ui=ui, server=server)
I'm experimenting a Shiny App to show dynamic contexts, but I cannot get renderDataTable working into a renderUi component.
Below two simple replicable tests: the first one is not working, the second one without renderUi works fine, of course.
What is the conceptually difference between this two, and why the first one cannot work in Shiny?
This one not works: note that the uiOutput myTable, contains two reactive component, a selectInput and a renderDataTable, but only the selectInput is rendered.
library(shiny)
runApp(list(
ui = fluidPage(
fluidRow(h2("where is the table?")),
uiOutput('myTable')
),
server = function(input, output) {
output$myTable <- renderUI({
fluidPage(
fluidRow(selectInput("test", "test", c(1,2,3))),
fluidRow(renderDataTable(iris))
)
})
}
))
This is fine, both selectInput and renderDataTable are rendered:
library(shiny)
runApp(list(
ui = fluidPage(
fluidRow(h2("where is the table?")),
fluidRow(selectInput("test", "test", c(1,2,3))),
fluidRow(dataTableOutput('myTable'))
),
server = function(input, output) {
output$myTable = renderDataTable(iris)
}
))
How to get the first scenario working?
Thanks.
EDITING after Yihui comment (thanks Yihui):
In renderUi has to be used some ui function, and not some render function:
changed the sample code in the correct way, the result does not change: still no data is shown.
library(shiny)
runApp(list(
ui = basicPage(
uiOutput('myTable')
),
server = function(input, output) {
output$myTable <- renderUI({dataTableOutput(iris)
})
}
))
EDIT n.2
Just solved, got it working so:
library(shiny)
runApp(list(
ui = fluidPage(
mainPanel(
uiOutput('myTable')
)
),
server = function(input, output) {
output$myTable <- renderUI({
output$aa <- renderDataTable(iris)
dataTableOutput("aa")
})
}
))
I have to save the renderTableOutput in a output variable first, and then feeding it to dataTableOutput.
Thanks for pointing me to: here
It would be clearer if you split the part of datatable generation and ui generation :
library(shiny)
runApp(list(
ui = fluidPage(
mainPanel(
uiOutput('myTable')
)
),
server = function(input, output) {
output$aa <- renderDataTable({iris})
output$myTable <- renderUI({
dataTableOutput("aa")
})
}
))