how to display two data outputs in an interactive html report using shiny

I have two data outputs as below.I want to display them in an interactive html report using shiny.How can i do that as i am new to shiny.

max_usage_hours_per_region<-setNames(aggregate(df3_machine_region$sum_as_hours~df3_machine_region$Region,df3_machine_region,max),c("Region","Sum_as_Hours"))

Region Sum_as_Hours
1 Africa 1156.0833
2 Americas 740.1667
3 APAC 740.2833
4 Europe 1895.2000
5 PDO 1053.3500
6 UK 0.0000

mean_usage_hours_per_region<-setNames(aggregate(df3_machine_region$sum_as_hours~df3_machine_region$Region,df3_machine_region,mean),c("Region","Sum_as_Hours"))
Region Sum_as_Hours
1 Africa 1.7046559
2 Americas 0.7578695
3 APAC 7.5799541
4 Europe 4.9651339
5 PDO 8.2637964
6 UK 0.0000000

I want to have region as the input bar/field wrt both the above functions for which user can select options for which the data will be accordingly displayed.

Suggest you find a tutorial online.

https://shiny.rstudio.com/tutorial/

As for dataframes, you can display them using the dataTableOutput() widget.

Thanks for the info.Well i tried using one of the code in rshiny but the table is not rendering.Please see the example below.

library(shiny)

ui <- fluidPage(
selectInput("Region","Select Region",max_usage_hours_per_region$Region,selected = TRUE)
)
server <- function(input, output) {
output$table <- renderTable(
max_usage_hours_per_region[,input$Region])
}
shinyApp(ui = ui, server = server)

The output is like below:

you would need to have a corresponging ui placeholder in your UI, otherwise shiny wouldnt know where to render the output$table to

ui <- fluidPage(
selectInput("Region","Select Region",max_usage_hours_per_region$Region,selected = TRUE),
tableOutput("table")
)

I have tried giving that too.But after i have that code and run it,it gives an error on the browser as undefined columns selected.

if your table doesnt have an Africa column, that would be expected.

Africa is just one of the values in the Region column like Americas.I have already selected Region column in the select input function under ui component.

right, so the code would fail also in a simple r script, (i.e. its not a shiny issue), but a how do I filter rows in and out of a table issue.
I recommend you learn to use a tidyverse approach, the book is excellent and you can rapidly be very productive.

You can head to chapter 5 (after installing the relevant packages - chapter 3.1.1 Prerequisites)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.