I would like to create an app using Shiny for Financial purposes. My idea is to use some financial indicators such as slidebars to filter companies. The main thinking process is this "If a company satisfies these indicators then it is successful", so I want that changing parameters on the left-hand side part of the app, shiny would have as output not only the companies satisfying the selected data but also the name of these.
How should I proceed to build this app? Should I create a dataframe to be inserted at the beginning of the app, if that's the case how do you suggest starting?
Thank you for your help!
Since you haven't provided a reproducible example or at least how your data looks, I created this small app that could give you an idea about how to start.
Basically, it has 3 sliderInput
s and the data is filtered by each slider following the condition "the value is greater or equal than the selected value from the slider".
This is an example, the data is filtered by:
So you will only see the rows that fulfill those conditions (at the same time). You can also see the rest of the columns including the "model" (that could be the name of the company in your case) after filtering.
I hope it helps.
Code:
library(shiny)
data <- mtcars
data$Model <- rownames(mtcars)
ui <- fluidPage(
titlePanel("My app"),
sidebarLayout(
sidebarPanel(
sliderInput(inputId = "slider1_mpg", label="Slider 1: mpg", min = min(data$mpg), max = max(data$mpg), value = min(data$mpg)),
sliderInput(inputId = "slider2_cyl", label="Slider 2: cyl", min = min(data$cyl), max = max(data$cyl), value = min(data$cyl)),
sliderInput(inputId = "slider3_qsec", label="Slider 3: qsec", min = min(data$qsec), max = max(data$qsec), value = min(data$qsec)),
),
mainPanel(
dataTableOutput("table")
)
)
)
server <- function(input, output, session) {
filtered_data <- reactive({
data[(data$mpg >= input$slider1_mpg) & (data$cyl >= input$slider2_cyl) & (data$qsec >= input$slider3_qsec),]
})
output$table <- renderDataTable({
filtered_data()
})
}
shinyApp(ui, server)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.