I am trying to develop a application, where the user can upload the file. The variables from the uploaded file should be displayed in the form of group checkbox and convert their datatype into numeric or date format according to user selection.
I have designed the dashboard in such a way that I have two sub menu items. Sub menu item 1, has loading of file and sub menu item 2 has preparation section.
1. The selection of variables are displayed in the Load menu instead of prep
2. Also, the render UI for variables, are displaying some irrelevant information and not the information I need.
library(shinydashboard)
ui<-dashboardPage(
dashboardHeader(title = "Model"),
dashboardSidebar(
sidebarMenu(id="tabs",
menuItem("Data", tabName = "data", icon = icon("table"),startExpanded = TRUE,
menuSubItem("Load", tabName = "data1"),
menuSubItem("Prep", tabName = "prep")
),
menuItem("Visualisation",icon=icon("bar-chart-o"), tabName = "vis"),
menuItem("Result", icon=icon("cog"), tabName = "result")
)
),
dashboardBody(
tags$style(type="text/css",
".shiny-output-error { visibility: hidden; }",
".shiny-output-error:before { visibility: hidden; }"
),
tabItems(
tabItem(tabName = "data1",
fluidPage(
fluidRow(
fileInput("file1","Choose CSV File",
accept = c("text/csv",
"text/comma-seperated-values, text/plain",
".csv")
),
tags$hr(),
checkboxInput("header", "Header", TRUE),
radioButtons("sep","Separator",
choices=c(Comma=",",
semicolon=";",
Tab="\t"),
selected = ";")
),
mainPanel(
uiOutput("tb")
)
)
)
),
tabItem(tabName = "prep",
fluidPage(
fluidRow(
mainPanel(
uiOutput("Pre")
)
)
))
)
)
server <- shinyServer(function(input,output){
data <- reactiveVal()
observeEvent(input$file1, ignoreNULL = T, ignoreInit = T,{
file1 <- input$file1
if(is.null(file1)){return()}
read.csv(file = file1$datapath, sep=input$sep)
})
output$filedf <- renderTable({
if(is.null(data())){return()}
input$file1
})
output$sum <- renderTable({
if(is.null(data())){return()}
summary(data())
})
output$table <- renderTable({
if(is.null(data())){return()}
data()
})
output$tb <- renderUI({
if(is.null(data())){return()}
tabsetPanel(tabPanel("About file", tableOutput("filedf")),tabPanel("Data", tableOutput("table")),tabPanel("Summary", tableOutput("sum")))
})
#----- Data Preparation------
observeEvent({input$data_option
input$data},
{
if(input$data_option=="var_attr"&
!is.null(input$data)
){
var.names <- names(input$data)
var.class <- NULL
}
})
})
shinyApp(ui,server)
Can anyone guide me , how i could avoid the error and achieve my target. I am unsure on how I could later convert the datatype for them.