How to use tmap with shiny - r

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)

Related

renderPlot outputs plot in View, not browser

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)

Cannot render flow chart in R shiny

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)

How to use R hands on table with shiny App

I am trying to create a shiny app using rhandsontable. I am using the code below:
library(shiny)
library(rhandsontable)
library(ggplot2)
ui = fluidPage(
rHandsontableOutput ('table'))
server = function(input, output, session) {
output$table < renderRHandsontable(mpg)}
shinyApp(ui, server)
When i run the code i get error "rendering objects from shinyoutput not allowed"
Any idea why its happening ?
This should do:
library(shiny)
library(rhandsontable)
library(ggplot2)
ui <- fluidPage(
mainPanel(
rHandsontableOutput('table')
)
)
server = function(input, output, session) {
output$table <- renderRHandsontable({
rhandsontable(head(mpg))
})
}
shinyApp(ui, server)

I am building shiny dashboard where I need to render table dynamically..my code below

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)

How to build simple google chart in Shiny

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() }) })

Resources