I have an R shiny app that allows users to upload a dataset, interactively subset it and then save it to the server. I also have several test files that are structured just like the files expected from the future users. I would like to write an automated testing script that uploads one of the datasets, randomly subsets the table (selecting rows in datatable, clicking action buttons) and then clicks a button to save it to the server. The user input to the app should be partly random and I need the clickstream of the user as an output to compare it to the saved dataset.
Is there a way to do this with shinytest or is that just for predefined clickstreams?
Related
I work on a Shiny app with multiple reactive variables as well as output objects scattered in numerous tabItems.
The idea behind this app is that on the first page you download a selected dataset, through an action button, that will be used by the entire app. After having created multiple reactive values and output objects when the user will explore the app, I would like to know if there is a simple way to re-initialize the application (reactive variables, output objects) as soon as we download another dataset thanks to the previous action button I have mentionned earlier.
In fact, I want to delete the value of reactive variables and output objects from the memory every time I click on this specific button and DL a new dataset.
I want this app to be the same as it is when I launch my code for the first time.
Regards
Thibaut
I tried to use reactive values a lot but it has to be done for every variables.
Perhaps, there is a simpler way.
I've created a shiny app that creates a graph based on data that's entered in daily via a shared excel sheet (.xlsx) that is in a shared folder (an L drive).
How would I format or upload the data so that it is able to be refreshed whenever a new daily line of data is entered?
Here is one possible approach along with reference documentations:
Create a workflow to fetch the data using its URL:
read in online xlsx - sheet in R
Make the data retrieval process reactive:
https://shiny.rstudio.com/articles/reactivity-overview.html
Set a reactiveTimer to periodically check for updates:
https://shiny.rstudio.com/reference/shiny/1.0.0/reactiveTimer.html
By doing so, your app will fetch the document on a regular basis to update your graph. If you want real time updates (i.e. every time there is a change in the document), you have to be able to trigger the application from outside, which is more complicated (especially via Excel).
Update:
Following up your comment; you don't need the data to be online. You are fine if you are able to import it into R. Just make this process reactive and set a timer to refresh everyday (see the documentation for examples). Alternatively you can have an actionButton to refresh manually.
I've written a function that takes a data frame of specific points and plots them using ggplot, creating a picture. I'd like to be able to take this picture and use it as a GUI for a Shiny app, where users can click anywhere on the picture, add some information from the click, and then append the click's coordinates and information to a data frame (that's originally empty). Ideally this data frame would be able to be downloaded for further analyses.
Is this possible? If so, how do I go about including the functionality in the Shiny app? I'd share code, but the data frame is long and I don't have anything in the Shiny app yet to share. More specific information about the project upon request.
In my shiny application, I would like to have a textarea field that allows the users to give text input. This can be done with:
ui.R:
tags$textarea(id="item",rows=3,cols=40,placeholder="Type your message...")
verbatimTextOutput("news")
server.R:
output$news <- renderText(input$item)
With this code, I can only see the text input within the current session of the app. My goal is, to save user text input permanently in the app (user gives text input, submits and data will be displayed in the app permanently).
Is this possible with shiny? My idea was to store the data in a global way like googlesheets.
One option is to write the text entry to disk as a plain text file, likely each time the user chooses to (e.g., by hitting a "Submit" button). You can use an actionButton and have an observeEvent that includes the code to save to disk.
Note that you will need to have unique file names to avoid overwriting. You could either use time stamps or take a look at the uuid package to generate random names.
If you are more comfortable with databases, you could, alternatively, set up a SQL table and append a line for each user submission (this would be substantially more reliable, allow you to store meta data with it, and avoid the file naming issues above).
Shiny itself is not designed to store data, though the authors have written up some suggested approaches (available here).
I'm wondering if it's possible for a shiny app that's not run on the web (i.e. it's only run by a user launching it from their R session) to assign values to objects in the user's global environment. For example, suppose that as part of the app a data.frame is generated and, instead of using a download button to save the data.frame to a file, is it possible to assign it to an object in the user's R session so that when they close the app the data.frame is available to them?
What about automatically save the entire environment (using "save" function) to a temporary file? Then, you can just load it (using "load" function) and your data frame will be in the environment. All this process can be easily automated, without needing to use any save button.