I am trying to add an input file in a flexdashboard, but I am a little confused. Previously I created a function to generate a plot, and then I call the function renderPlot with the function in order to get the plot in the dashboard.
R flexdashboard and shiny interactive plot
But now, If I create a function to read the file I don´t understand how to call it.
How to follow the same idea, create a function that read a file with an input file in the dashboard and then perform the analysis in the dashboard.
I have generated this code
---
title: "Untitled"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
---
```{r setup, include=FALSE}
library(flexdashboard)
library(shiny)
```
Column {.sidebar}
-----------------------------------------------------------------------
```{r, echo = FALSE}
fileInput("file1", "Choose CSV File",
multiple = TRUE,
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv"))
```
With this I have obtained a side bar with the File Input. but how to use that uploaded file in any analysis and show the results in the dashboard?
---
title: "Untitled"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
---
```{r setup, include=FALSE}
library(flexdashboard)
library(shiny)
```
Column {.sidebar}
-----------------------------------------------------------------------
```{r, echo = FALSE}
fileInput("file1", "Choose CSV File",
multiple = TRUE,
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv"))
df_reac <- reactive({
read_xlsx(file1$datapath)
})
```
Column{data-width=300}
-----------------------------------------------------------------------
```{r, echo = FALSE}
renderTable(df_reac)
```