it looks to me like all the code to make the selectise works just fine. although there is redundant/useless code here
colnames(df)
because this is not reactive, and theres not even a df object in scope of the this ui declation.
I think you have a more fundamental problem in that your code wont even run at all.
I expect a shiny app to be structured like :
library(shiny)
ui <- fluidPage(
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
but you had shinyUI(dashboardPage rather than ui <-dashboardPage
shinyUI is not a function I'm aware of...
and you omit to have the shinyApp() function call at the end.
I had to fix some mismatch braces errors.
hey, this still has whatever problems, but the selectize 'works' and it executes.
library(DT)
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(ggvis)
library(ggplot2)
library(dplyr)
shinyUI<-dashboardPage(
dashboardHeader(title = "Data Visualization"),
dashboardSidebar(
width = 350,
radioButtons(
"fileType_Input",
label = h4("Choose File type"),
choices = list(".csv/txt" = 1, ".xlsx" = 2),
selected = 1,
inline = TRUE
),
fileInput(
'file1',
h4('Upload Your Data'),
accept = c(
'text/csv',
'text/comma-separated-values,text/plain',
'.csv',
'.xlsx'
)),
sidebarMenu(
selectInput(inputId = "x", label = "Select x-axis Variable:",choices = NULL),
selectInput(inputId = "y", label = "Select y-axis Variable:",choices = NULL),
menuItem("Raw Data", tabName = "RawData",
icon = icon("table")),
menuItem("Data Summary", tabName = "DataSummary",
icon = icon("calculator")),
menuItem("Charts", tabName = "Charts",
icon = icon("chart-bar"))
)),
dashboardBody(
tabItems(
tabItem( tabName = "RawData",
fluidRow(
box(
title = "View Data",
width = NULL,
status = "primary",
solidHeader = TRUE,
collapsible = TRUE,
DT::dataTableOutput('contents'))
)),
tabItem(tabName = "DataSummary",
box(verbatimTextOutput("summary"))
),
tabItem(tabName = "Charts",
box(
plotOutput('plot'))
)
))
)
server <- function(input, output, session) {
myData <- reactive({
req(input$file1)
inFile <- input$file1
if (is.null(inFile)) return(NULL)
data <- read.csv(inFile$datapath, header = TRUE)
data
})
output$contents <- DT::renderDataTable({
DT::datatable(myData())
})
observe({
data <- myData()
updateSelectInput(session, 'x', choices = names(data))
})
#gets the x variable name, will be used to change the plot legends
xVarName <- reactive({
input$x
})
observe({
data <- myData()
updateSelectInput(session, 'y', choices = names(data))
})
#gets the y variable name, will be used to change the plot legends
yVarName <- reactive({
input$y
})
output$summary <- renderPrint({
summary(myData())
})
output$select <- renderUI({
df <- myData()
selectInput("variable", "Variable:",names(df))
})
output$plot <- renderPlot({
df <- myData()
df <- df[,input$variable]
ggplot(df, aes_string(x = input$x, y = input$y))+
geom_line()
})
}
shinyApp(shinyUI, server)