Spinner from shinycssloaders package loads before pressing the action button - r

I am creating a shiny app with some tabs and I am using the shinycssloaders package in order to show a spinner AFTER pressing the actionButton. I saw this post because I was having the same problem... I followed the solution that it was given to the post, but as I my app is different (it has tabPanels, it doesn't work properly, the spinner still apears).
For example, if you click on "Show the plot" in the first tab (selection) and then you want to want to do the log2 transformation o calculate the square root (3rd tab, calculations), before clicking the actionButton the spinner appears and the plot updates. It happens the same when you want to change the titles (2nd tab).
Does anyone know how to fix it?
Thanks very much in advance
The code:
library(shiny)
library(magrittr)
library(DT)
library(ggplot2)
library(shinycssloaders)
new_choices <- setNames(names(mtcars), names(mtcars))
ui <- fluidPage(
# Application title
titlePanel("My shiny app"),
sidebarLayout(
sidebarPanel(
tabsetPanel(
tabPanel("Selection",
selectInput("x_axis", "Choose x axis",
choices = new_choices),
selectInput("y_axis", "Choose y axis",
choices = new_choices),
hr(),
),
tabPanel("Titles",
hr(),
textInput(inputId = "title", "You can write the title:", value = "This is the title"),
textInput(inputId = "xlab", "You can re-name the x-axis:", value = "x-axis...."),
textInput(inputId = "ylab", "You can re-name the y-axis:", value = "y-axis ...."),
),
tabPanel("Calculations",
hr(),
checkboxInput("log2", "Do the log2 transformation", value = F),
checkboxInput("sqrt", "Calculate the square root", value = F),
)
),
actionButton(inputId = "drawplot", label = "Show the plot")
),
# Show a plot of the generated distribution
mainPanel(
# plotOutput("plot")
uiOutput("spinner"),
)
)
)
server <- function(input, output, session) {
data <- reactive({
mtcars
})
filtered_data <- reactive({
data <- data()
if(input$log2 == TRUE){
data <- log2(data+1)
}
if(input$sqrt == TRUE){
data <- sqrt(data)
}
return(data)
})
observeEvent(input$drawplot, {
output$spinner <- renderUI({
withSpinner(plotOutput("plot"), color="black")
})
output$plot <- renderPlot({
Sys.sleep(3)
ggplot() +
geom_point(data = filtered_data(),
aes_string(x = input$x_axis, y = input$y_axis)) +
xlab(input$xlab) +
ylab(input$ylab) +
ggtitle(input$title)
})
})
}
shinyApp(ui, server)

Is it OK like this? I'm not sure to understand all your requirements. To avoid the spinner at the start-up, I use a conditionalPanel. In the server code, I did some changes. It is not recommended to define some output inside an observer.
library(shiny)
library(magrittr)
library(ggplot2)
library(shinycssloaders)
new_choices <- setNames(names(mtcars), names(mtcars))
ui <- fluidPage(
# Application title
titlePanel("My shiny app"),
sidebarLayout(
sidebarPanel(
tabsetPanel(
tabPanel(
"Selection",
selectInput("x_axis", "Choose x axis",
choices = new_choices),
selectInput("y_axis", "Choose y axis",
choices = new_choices),
hr(),
),
tabPanel(
"Titles",
hr(),
textInput(inputId = "title", "You can write the title:", value = "This is the title"),
textInput(inputId = "xlab", "You can re-name the x-axis:", value = "x-axis...."),
textInput(inputId = "ylab", "You can re-name the y-axis:", value = "y-axis ...."),
),
tabPanel(
"Calculations",
hr(),
checkboxInput("log2", "Do the log2 transformation", value = F),
checkboxInput("sqrt", "Calculate the square root", value = F),
)
),
actionButton(inputId = "drawplot", label = "Show the plot")
),
# Show a plot of the generated distribution
mainPanel(
conditionalPanel(
condition = "input.drawplot > 0",
style = "display: none;",
withSpinner(plotOutput("plot"))
)
)
)
)
server <- function(input, output, session) {
data <- reactive({
mtcars
})
filtered_data <- reactive({
data <- data()
if(input$log2 == TRUE){
data <- log2(data+1)
}
if(input$sqrt == TRUE){
data <- sqrt(data)
}
return(data)
})
gg <- reactive({
ggplot() +
geom_point(data = filtered_data(),
aes_string(x = input$x_axis, y = input$y_axis)) +
xlab(input$xlab) +
ylab(input$ylab) +
ggtitle(input$title)
}) %>%
bindEvent(input$drawplot)
output$plot <- renderPlot({
Sys.sleep(3)
gg()
})
}
shinyApp(ui, server)

You need to isolate the expressions that you don't want to trigger the rendering event inside renderPlot
library(shiny)
library(magrittr)
library(DT)
library(ggplot2)
library(shinycssloaders)
new_choices <- setNames(names(mtcars), names(mtcars))
ui <- fluidPage(
# Application title
titlePanel("My shiny app"),
sidebarLayout(
sidebarPanel(
tabsetPanel(
tabPanel("Selection",
selectInput("x_axis", "Choose x axis",
choices = new_choices),
selectInput("y_axis", "Choose y axis",
choices = new_choices),
hr(),
),
tabPanel("Titles",
hr(),
textInput(inputId = "title", "You can write the title:", value = "This is the title"),
textInput(inputId = "xlab", "You can re-name the x-axis:", value = "x-axis...."),
textInput(inputId = "ylab", "You can re-name the y-axis:", value = "y-axis ...."),
),
tabPanel("Calculations",
hr(),
checkboxInput("log2", "Do the log2 transformation", value = F),
checkboxInput("sqrt", "Calculate the square root", value = F),
)
),
actionButton(inputId = "drawplot", label = "Show the plot")
),
# Show a plot of the generated distribution
mainPanel(
# plotOutput("plot")
uiOutput("spinner"),
)
)
)
server <- function(input, output, session) {
data <- reactive({
mtcars
})
filtered_data <- reactive({
data <- data()
if(input$log2 == TRUE){
data <- log2(data+1)
}
if(input$sqrt == TRUE){
data <- sqrt(data)
}
return(data)
})
observeEvent(input$drawplot, {
output$spinner <- renderUI({
withSpinner(plotOutput("plot"), color="black")
})
output$plot <- renderPlot({
Sys.sleep(3)
ggplot() +
geom_point(data = isolate(filtered_data()),
aes_string(x = isolate(input$x_axis), y = isolate(input$y_axis))) +
xlab(isolate(input$xlab)) +
ylab(isolate(input$ylab)) +
ggtitle(isolate(input$title))
})
})
}
shinyApp(ui, server)
Read more about shiny reactivity and isolation: https://shiny.rstudio.com/articles/isolation.html

Related

ggplot2 mutate error when select variable from uploaded dataset in R shinydashbard

I am trying to plot using ggplot in R shiny. I want to upload data and any variable can be used for plotting. I am trying to keep aes() dynamically. I tried a few examples example 1, but dint work for me. Here is my code:
library(shiny)
library(shinydashboard)
library(readxl)
library(DT)
library(dplyr)
library(ggplot2)
# Define UI for application that draws a histogram
ui <- fluidPage(
titlePanel("Uploading Files"),
sidebarLayout(
sidebarPanel(
fileInput('file1', 'Upload data File',
accept=c('text/csv','.xlsx',
'text/comma-separated-values,text/plain',
'.csv'))),
mainPanel(
DT::dataTableOutput('contents')
)
),
tabPanel("First Type",
pageWithSidebar(
headerPanel('Visualization of Dengue Cases'),
sidebarPanel(
selectInput('xcol', 'X Variable', ""),
selectInput('ycol', 'Y Variable', "", selected = "")
),
mainPanel(
plotOutput('MyPlot')
)
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output,session) {
data <- reactive({
req(input$file1)
inFile <- input$file1
df <- read_excel(paste(inFile$datapath, sep=""), 1)
updateSelectInput(session, inputId = 'xcol', label = 'X Variable',
choices = names(df), selected = names(df))
updateSelectInput(session, inputId = 'ycol', label = 'Y Variable',
choices = names(df), selected = names(df)[2])
return(df)
})
output$contents <- DT::renderDataTable({
data()
},options = list(pageLength = 10, width="100%", scrollX = TRUE))
output$MyPlot <- renderPlot({
select_quo <- quo(input$MyPlot_select)
data %>%
mutate(user_input = !!select_quo) %>%
ggplot(aes(fill=user_input, y=user_input, x= user_input)) +
geom_bar( stat="identity")
})
}
# Run the application
shinyApp(ui = ui, server = server)
Can use any data set, such as Diamond dataset.
Also kindly help in allowing all types of formats (.csv, .txt,.xls) of data. As of now, only .xls is acceptable.
There are several issues with your code.
You use data instead of data() in the renderPlot
There is no input input$MyPlot_select.
Using quo and !! will not give the desired result. Instead you could simply use the .data pronoun if your column names are strings.
Add req at the beginning of renderPlot.
This said your renderPlot should look like so:
output$MyPlot <- renderPlot({
req(input$xcol, input$ycol)
x <- input$xcol
y <- input$ycol
fill <- input$xcol
ggplot(data(), aes(x = .data[[x]], y = .data[[y]], fill=.data[[fill]])) +
geom_col()
})
For the second part of your question. To make your app work for different types of input files you could get the file extension using e.g. tools::file_ext and use the result in switch statement.
Full reproducible code:
library(shiny)
library(shinydashboard)
library(readxl)
library(DT)
library(dplyr)
library(ggplot2)
ui <- fluidPage(
titlePanel("Uploading Files"),
sidebarLayout(
sidebarPanel(
fileInput("file1", "Upload data File",
accept = c(
"text/csv", ".xlsx",
"text/comma-separated-values,text/plain",
".csv"
)
)
),
mainPanel(
DT::dataTableOutput("contents")
)
),
tabPanel(
"First Type",
pageWithSidebar(
headerPanel("Visualization of Dengue Cases"),
sidebarPanel(
selectInput("xcol", "X Variable", ""),
selectInput("ycol", "Y Variable", "", selected = "")
),
mainPanel(
plotOutput("MyPlot")
)
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output, session) {
data <- reactive({
req(input$file1)
inFile <- input$file1
type <- tools::file_ext(inFile$name)
filename <- inFile$datapath
df <- switch(type,
"xlsx" = read_excel(filename),
"csv" = read_csv(filename),
"tsv" = read_tsv(filename))
updateSelectInput(session,
inputId = "xcol", label = "X Variable",
choices = names(df), selected = names(df)
)
updateSelectInput(session,
inputId = "ycol", label = "Y Variable",
choices = names(df), selected = names(df)[2]
)
return(df)
})
output$contents <- DT::renderDataTable({
data()
}, options = list(pageLength = 10, width = "100%", scrollX = TRUE))
output$MyPlot <- renderPlot({
req(input$xcol, input$ycol)
x <- input$xcol
y <- input$ycol
fill <- input$xcol
ggplot(data(), aes(x = .data[[x]], y = .data[[y]], fill=.data[[fill]])) +
geom_col()
})
}
# Run the application
shinyApp(ui = ui, server = server)

Loading bar from Waiter package doesn't disappear after its use [SHINY]

I am creating a Shiny app and I have started using the Waiter package.
When I load the app, before doing anything, we cannot see anything (at it is expected). When I generate the plot, the loading bar appears but when it finishes, it doesn't disappear. It stays a white box that it still can be seen.
Loading....
It has finished.
Does anyone know how to remove it?
Thanks in advance!
Code:
library(shiny)
library(magrittr)
library(DT)
library(ggplot2)
library(waiter)
new_choices <- setNames(names(mtcars), names(mtcars))
ui <- fluidPage(
# Application title
titlePanel("My shiny app"),
sidebarLayout(
sidebarPanel(
tabsetPanel(
tabPanel("Selection",
selectInput("x_axis", "Choose x axis",
choices = new_choices),
selectInput("y_axis", "Choose y axis",
choices = new_choices),
hr(),
),
tabPanel("Titles",
hr(),
textInput(inputId = "title", "You can write the title:", value = "This is the title"),
textInput(inputId = "xlab", "You can re-name the x-axis:", value = "x-axis...."),
textInput(inputId = "ylab", "You can re-name the y-axis:", value = "y-axis ...."),
),
tabPanel("Calculations",
hr(),
checkboxInput("log2", "Do the log2 transformation", value = F),
checkboxInput("sqrt", "Calculate the square root", value = F),
)
),
useWaitress(),
actionButton(inputId = "drawplot", label = "Show the plot")
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("plot"),
)
)
)
server <- function(input, output, session) {
waitress <- Waitress$new(theme = "overlay-percent", min = 0, max = 10)
data <- reactive({
mtcars
})
filtered_data <- reactive({
data <- data()
if(input$log2 == TRUE){
data <- log2(data+1)
}
if(input$sqrt == TRUE){
data <- sqrt(data)
}
return(data)
})
v <- reactiveValues()
observeEvent(input$drawplot, {
# use notification
waitress$notify()
for(i in 1:10){
waitress$inc(1) # increase by 10%
Sys.sleep(.3)
}
v$plot <- ggplot() +
geom_point(data = filtered_data(),
aes_string(x = input$x_axis, y = input$y_axis)) +
xlab(input$xlab) +
ylab(input$ylab) +
ggtitle(input$title)
waitress$close() # hide when done
})
output$plot <- renderPlot({
if (is.null(v$plot)) return()
v$plot
})
}
shinyApp(ui, server)
Feels like a bug to me. You may file an issue to the waiter github repository and ask them to fix it. Meanwhile, a workaround we can do is to manually show and hide the bar by ourselves.
library(shiny)
library(magrittr)
library(DT)
library(ggplot2)
library(waiter)
library(shinyjs)
new_choices <- setNames(names(mtcars), names(mtcars))
ui <- fluidPage(
# Application title
titlePanel("My shiny app"),
sidebarLayout(
sidebarPanel(
tabsetPanel(
tabPanel("Selection",
selectInput("x_axis", "Choose x axis",
choices = new_choices),
selectInput("y_axis", "Choose y axis",
choices = new_choices),
hr(),
),
tabPanel("Titles",
hr(),
textInput(inputId = "title", "You can write the title:", value = "This is the title"),
textInput(inputId = "xlab", "You can re-name the x-axis:", value = "x-axis...."),
textInput(inputId = "ylab", "You can re-name the y-axis:", value = "y-axis ...."),
),
tabPanel("Calculations",
hr(),
checkboxInput("log2", "Do the log2 transformation", value = F),
checkboxInput("sqrt", "Calculate the square root", value = F),
)
),
useWaitress(),
useShinyjs(),
actionButton(inputId = "drawplot", label = "Show the plot")
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("plot")
)
)
)
server <- function(input, output, session) {
waitress <- Waitress$new(theme = "overlay-percent", min = 0, max = 10)
data <- reactive({
mtcars
})
filtered_data <- reactive({
data <- data()
if(input$log2 == TRUE){
data <- log2(data+1)
}
if(input$sqrt == TRUE){
data <- sqrt(data)
}
return(data)
})
v <- reactiveValues()
observeEvent(input$drawplot, {
# use notification
show(selector = '.waitress-notification.notifications')
waitress$notify()
for(i in 1:10){
waitress$inc(1) # increase by 10%
Sys.sleep(.3)
}
v$plot <- ggplot() +
geom_point(data = filtered_data(),
aes_string(x = input$x_axis, y = input$y_axis)) +
xlab(input$xlab) +
ylab(input$ylab) +
ggtitle(input$title)
waitress$close()
hide(selector = '.waitress-notification.notifications')
})
output$plot <- renderPlot({
if (is.null(v$plot)) return()
v$plot
})
}
shinyApp(ui, server)

Plot the boxplot by using check box in shiny app

I'd like to use check box input to allow to show different island levels (within the categorical variable selected for the x-axis) with separate boxplots and different colors with a legend. But if this check box is not selected, I just want to show boxplot without fill=legend that is:
ggplot(dat(), aes_string(x = isolate(input$xaxis), y = input$yaxis)) +
geom_boxplot()
This R code is what I tried to use but It didn't work. Could you please help me to solve or tell me what makes error with my R code?
Thank you in advance
library(shiny)
library(palmerpenguins)
library(ggplot2)
library(dplyr)
penguin <- penguins
penguin$year <- as.factor(penguin$year)
ui <- fluidPage(
titlePanel("Data Visualisation of Penguins Data"),
sidebarPanel(
selectInput("yaxis",
label = "Choose a y-axis variable to display",
choices = list("bill_length_mm",
"bill_depth_mm",
"flipper_length_mm",
"body_mass_g"),
selected = "bill_length_mm"),
selectInput("xaxis",
label = "Choose a x-axis variable to display",
choices = c("species",
"sex",
"year"),
selected = "sex"),
checkboxGroupInput("islandlevels",
label = "Check to display different island levels",
choices = c("island"),
selected = NULL),
br(), br(),
selectInput("species",
label = "Choose species to view separate plot",
choices = list("Adelie",
"Chinstrap",
"Gentoo"),
selected = NULL)),
mainPanel(
plotOutput("plot1"),
br(), br(),
plotOutput("plot2")
)
)
server <- function(input, output){
dat <- reactive({
if(input$xaxis == "sex") penguin[!is.na(penguin$sex),] else penguin
})
output$plot1 <- renderPlot({
if(input$islandlevels == "island") {
req(penguin, input$xaxis, input$yaxis)
ggplot(dat(), aes_string(x = isolate(input$xaxis), y = input$yaxis, fill=island)) +
geom_boxplot()
}
if(input$islandlevels = NULL) {
req(penguin, input$xaxis, input$yaxis)
ggplot(dat(), aes_string(x = isolate(input$xaxis), y = input$yaxis)) +
geom_boxplot()}
})
}
shinyApp(ui = ui, server = server)
As long as you don't want any other checkbox inputs you could use a checkboxInput instead of a checkboxGroupInput which makes checking a bit easier.
One issue in your server was that you used island instead of "island". Additionally you can simplify your code a little bit by using fill <- if (input$islandlevels) "island" which will return NULL is the the checkbox was not checked and "island" otherwise. This way you can handle both case with only one ggplot statement .
The full reproducible code:
library(shiny)
library(palmerpenguins)
library(ggplot2)
library(dplyr)
penguin <- penguins
penguin$year <- as.factor(penguin$year)
ui <- fluidPage(
titlePanel("Data Visualisation of Penguins Data"),
sidebarPanel(
selectInput("yaxis",
label = "Choose a y-axis variable to display",
choices = list("bill_length_mm",
"bill_depth_mm",
"flipper_length_mm",
"body_mass_g"),
selected = "bill_length_mm"),
selectInput("xaxis",
label = "Choose a x-axis variable to display",
choices = c("species",
"sex",
"year"),
selected = "sex"),
checkboxInput("islandlevels",
label = "Check to display different island levels",
value = FALSE),
br(), br(),
selectInput("species",
label = "Choose species to view separate plot",
choices = list("Adelie",
"Chinstrap",
"Gentoo"),
selected = NULL)),
mainPanel(
plotOutput("plot1"),
br(), br(),
plotOutput("plot2")
)
)
server <- function(input, output){
dat <- reactive({
if(input$xaxis == "sex") penguin[!is.na(penguin$sex),] else penguin
})
output$plot1 <- renderPlot({
req(penguin, input$xaxis, input$yaxis)
fill <- if (input$islandlevels) "island"
ggplot(dat(), aes_string(x = isolate(input$xaxis), y = input$yaxis, fill = fill)) +
geom_boxplot()
})
}
shinyApp(ui = ui, server = server)

Multilines graph with uploaded CSV

I would like to be able to display a multi-line graph with an imported csv. CSV files contain time series. On import, I would like to be able to choose, knowing that the name of the fields can change according to the CSV, the field representing the X and the one of Y, and define the field containing the ID which will create the various lines. Something like this :
For now, I have this but it's completly wrong
# ui.R
library(shiny)
library(shinydashboard)
library(ggplot2)
shinyUI(
dashboardPage(
dashboardHeader(title ="Sen2extract"),
sidebar <- dashboardSidebar(
sidebarMenu(
menuItem("Chart", tabName = "chart")
)
),
dashboardBody(
tabItem(tabName = "chart",
box(
width = 12, collapsible=FALSE,
fileInput(inputId = "csv_chart", label = "Upload your CSV", multiple = FALSE,
accept = c(".csv", "text/csv", "text/comma-separated-values,text/plan"), width = "300px"),
selectInput("X", label = "Field X :", choices = list("Choice 1" = "")),
selectInput("Y", label = "Field Y :", choices = list("Choice 1" = "")),
selectInput("group", label = "Group by :", choices = list("Choice 1" = ""))
),
box(plotOutput("plot"), width = 12)
)
)
)
)
# server.R
library(shiny)
library(shinydashboard)
library(ggplot2)
shinyServer(function(input, output, session){
output$plot = renderPlot({
data <- read.csv(file = input$csv_chart)
ggplot(data) +
geom_line(mapping = aes(x = input$X, y = input$Y)) +
labs (x = "Years", y = "", title = "Index Values")
})
})
there were several issues with your code and I have a working version below.
The main issue was that you have to read your data within reactive() and then update the selection. Also, to have multiple lines in your graph, you have to add what to group on in ggplot when you define the mapping in aes or in this case aes_string. I chose color as this gives multiple lines colored according to different groups in the chosen column.
library(shiny)
library(shinydashboard)
library(tidyverse)
ui <- dashboardPage(
dashboardHeader(title ="Sen2extract"),
sidebar <- dashboardSidebar(
sidebarMenu(
menuItem("Chart", tabName = "chart")
)
),
dashboardBody(
tabItem(tabName = "chart",
box(
width = 12, collapsible=FALSE,
fileInput(inputId = "csv_chart", label = "Upload your CSV",
multiple = FALSE,
accept = c(".csv",
"text/csv",
"text/comma-separated-values,text/plan"),
width = "300px"),
selectInput("X", label = "Field X:", choices = "Pending Upload"),
selectInput("Y", label = "Field Y:", choices = "Pending Upload"),
selectInput("group", label = "Group by:", choices = "Pending Upload")
),
box(plotOutput("plot"), width = 12)
)
)
)
server <- function(input, output, session){
data <- reactive({
req(input$csv_chart)
infile <- input$csv_chart
if (is.null(infile))
return(NULL)
df <- read_csv(infile$datapath)
updateSelectInput(session, inputId = 'X', label = 'Field X:',
choices = names(df), selected = names(df)[1])
updateSelectInput(session, inputId = 'Y', label = 'Field Y:',
choices = names(df), selected = names(df)[2])
updateSelectInput(session, inputId = 'group', label = 'Group by:',
choices = names(df), selected = names(df)[3])
return(df)
})
output$plot <- renderPlot({
ggplot(data()) +
geom_line(mapping = aes_string(x = input$X, y = input$Y, color=input$group)) +
labs(x = "Years", y = "", title = "Index Values")
})
}
shinyApp(ui = ui, server = server)

R shiny app is not reactive

I have been working with the Shiny package, there is one function, which the user is able to select from a list of choices, based on the choice, the plot will update. however, right now the app does not update when the selection changes.
server.R
----------
library(shiny)
library(quantmod)
library(TTR)
shinyServer(function(input, output, session) {
selectedsymbol <- reactive({
symbol <- input$selectstock
})
output$stockplotoverview <- renderPlot({
symbolinput <- selectedsymbol()
getSymbols(symbolinput)
chartSeries(get(symbolinput))
addMACD()
addBBands()
})
output$candlechart <- renderPlot({
symbolinput <- input$selectstock
getSymbols(symbolinput)
candleChart(get(symbolinput),multi.col=TRUE,theme="white")
})
output$barchart <- renderPlot({
symbolinput <- input$selectstock
getSymbols(symbolinput)
barChart(get(symbolinput))
})
})
ui.R
library(shiny)
shinyUI(fluidPage(
# Application title
titlePanel("Hello Shiny!"),
# Sidebar component
sidebarLayout(
sidebarPanel(
selectInput("selectstockset", label = h3("Select the stock set"), choices = list("My Stock set" = 1,
"Good Stock Set" = 2,
"Customize" = 3), selected = 1),
selectInput("selectalgo", label = h3("Select the algorithm"), choices = list("Worst Increment" = 1,
"PAMR" = 2,
"SMA" = 3), selected = 1),
dateRangeInput("daterange", label = h3("Date Range")),
submitButton("Simulate")
),
# Show a plot of the generated distribution
mainPanel(
tabsetPanel(
tabPanel("Stock Set",
helpText("Select a stock to examine.
Information will be collected from yahoo finance."),
textInput("stocksetname", label = h4("Stock Set Name"),
value = "Enter text...") ,
# uiOutput("selectstock"),
selectInput("selectstock", label = h4("Select the stock"), choices = list("AAPL" = "AAPL",
"SBUX" = "SBUX",
"GS" = "GS")),
tabsetPanel(
tabPanel("Overview",
plotOutput("stockplotoverview")
),
tabPanel("Candle Chart",
plotOutput("candlechart")
),
tabPanel("Bar Chart",
plotOutput("barchart"))
),
hr(),
fluidRow(
column(3,
actionButton("addtostockset","Add to stock set"),
tags$style(type='text/css', "#addtostockset { align: right;}")
),
column(3,
actionButton("confirm","Confirm stock set"),
tags$style(type='text/css', "#confirm { align: right; }")
)
)),
tabPanel("Simulation Window"),
tabPanel("Statistical Result")
)
)
)))
Nothing is returned by your reactive conductor:
selectedsymbol <- reactive({
symbol <- input$selectstock
})
Use
selectedsymbol <- reactive({
symbol <- input$selectstock
return(symbol)
})

Resources