R Shiny Widget to csv using action button

I'm just starting out using R and Shiny, so I'm super new at both.

I've managed to build a simply Shiny app that has several types of widgets (checkbox, drop downs, number, and text input etc.). I have also added a submit button.

Example of one of my widgets:

       checkboxGroupInput("Check Group",
                          h4("Show Name"),
                          choices = list("Absent or Not Affected" = 0,
                                         "Affected" = 1),
                          selected = FALSE)

All the widgets work just fine.

The goal of the application is to have a user complete the form in total, meaning give all the widgets a new value, and then click submit. Once the user clicks submit a new row is written to a csv with all the user supplied values for the widgets.

Any super simple example of how to do that would be great. I can take that example and apply it to the rest of the application.

Cheers ~!

shiny has a downloadButton which will do this for you. You'll need to assemble the user data into a data.frame youself then save it as a csv.

So I don't want to download a file.
I need to update it every time the submit button is clicked.
I don't know much about data frames.
I'll look into that as well.

Right now I just the different types of widgets and where I want them.

Cheers~!

After vectors, data.frames are the main data structure in R. A data.frame is basically a list of vectors of the same length. A LOT of R functions work on data.frames. For example much of the tidyverse set of packages.

I recommend reading the online book "R for Data Science"

Where is the file you want to update? If it's a persistent file you need to read up on persistent storage in shiny apps (there's a page here at RStudio). You can read and write files from a shiny app but the challenge is where the file is located.

So the plan is to stick a csv file named something like "my_data" in the working directory for the app.
Then just have the app update that file when the submit button is clicked.

I'll check out the links you sent over as well.

I think I have a good set of bones.
Once I get the update data thing down it'll just be a matter of making my widgets work with the solution.

Cheers~!

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.