Reputation: 45
I am reading a csv file using shiny interface in a R markdown(RMD) file.
```{r, echo = FALSE}
shinyApp(
ui = fluidPage(
fluidRow(
column(3,
fileInput("file","Upload the file"),
helpText("Default max. file size is 5MB")
),
column(4,
tags$hr(),
h5(helpText("Select the read.table parameters below")),
checkboxInput(inputId = 'header', label = 'Header', value = TRUE),
checkboxInput(inputId = "stringAsFactors", "stringAsFactors", TRUE),
br()
),
column(5,
radioButtons(inputId = 'sep', label = 'Separator', choices = c(Comma=',',Semicolon=';',Tab='\t', Space=''), selected = ',')
),
mainPanel(
uiOutput("tb")
# use below code if you want the tabset programming in the main panel. If so, then tabset will appear when the app loads for the first time.
# tabsetPanel(tabPanel("Summary", verbatimTextOutput("sum")),
# tabPanel("Data", tableOutput("table")))
)
)
),
server = function(input, output) {
data <- reactive({
file1 <- input$file
if(is.null(file1)){return()}
read.table(file=file1$datapath, quote = NULL,header = TRUE, sep=input$sep, fill=TRUE,stringsAsFactors = input$stringAsFactors)
})
output$table <- renderTable({
if(is.null(data())){return ()}
head(data(),5)
})
output$tb <- renderUI({
if(is.null(data()))
return()
else
tabPanel("Data", tableOutput("table"))
})
},
)
```
Input data is now stored in data(). Later in my document i wish to create another shiny application and plot the histogram of this data.In this case i need to pass the variable data() to RMarkdown and later call that variable in the next shiny App. Is there any ways to do it?
Upvotes: 1
Views: 1687
Reputation: 495
Well, the solution to your problem is to create a layer application. Shiny does not work like html or php, you call the files and each file has its own code. Shiny only generates an html code (when you run the application).
Probably, you have some options to show the plot in a Shiny app:
In my experience, I used the navbar, to create a navigation panel, that you only see the selected menu. Moreover you can use the package shinyjs, that allows you to hide some elements, you when you want it.
Upvotes: 1