Hi guys,
I'm quite new with using Shiny. The code below is actually part of an Rmarkdown file with Shiny coding in it.
I have an issue in handling reactive expressions within Shiny. Basically after calling a reactive expression, I can render or plot the expressions. What I cannot easily do is to manipulate that data after calling it.
I've managed to render and output
load_table(). This just tells it to load the csv file on a button click. See code below:
```{r UI inputs}
wellPanel(
fileInput("dataset", label = "Select a .csv File to upload",
accept=c("text/csv",
"text/comma-separated-values,text/plain",
".csv")),
actionButton(inputId = "loadbutton", label = "Load Data")
)
dataTableOutput("df")
```
```{r Server Functions}
load_table <- eventReactive(input$loadbutton, {
# input$file1 will be NULL initially. After the user selects
# and uploads a file, it will be a data frame with 'name',
# 'size', 'type', and 'datapath' columns. The 'datapath'
# column will contain the local filenames where the data can
# be found.
inFile <- input$dataset
if (is.null(inFile)){
return(NULL)}
else {
read.csv(inFile$datapath)}
})
output$df <- renderDataTable({
load_table()
})
```
However, once the user selects and loads the data - I can't seem to
manipulate it because the reactive expressions doesn't work like a
dataframe. What I want to do next is to create filters so my users can
sift through
load_table(). But R never seems to treat it like a normal table. And I can't get the table without using a reactive function.
I know there are solutions out there on StackExchange, and there are issues similar to mine but I can never get it to really work.
Zac