Reset text output from R in spotfire - r

I have written a code to generate texts based on certain conditions in Spotfire using R. The code refreshes automatically whenever a selection is made. Since there are a lot of if-else condition used in R, the code takes a noticeable time to refresh the content. The dashboards change but the text changes after a lag.
Is there anyway to reset the text output while the R code runs so that the user doesn't get confused?

I've go some Python triggered data function that can take between 5 minutes to an hour to execute. The hardest part is getting the HTML of a text area to update. What I've currently implemented is a loading bar coded by Halpenfield. Something I've been meaning to try but haven't gotten to yet is a more descriptive popup.
These won't reset the displayed text before executing code but they will make it clear to the user something is happening. There might be a way to do directly what you are asking with two HTML's and a forced refresh like Halpenfield uses.

Related

Obtain values from Shiny context from cmd

I am looking to get the values from a reactive function, based on a specific set of inputs, but without the dashboard open or visible. Is this possible?
I have two possible solutions, both of them I am not sure are possible, and which of the two would be better. Also, I do think there could be a better solution.
Start the dashboard at a specific time and write away a csv with the required information. I don't know how to put the input values to the right settings though (they would be different from the normal initial settings). Hopefully start this without a visible endpoint (headless chromedriver for example).
Within Shiny, do a check if it's a specific time. If that's the case, change all inputs to the right settings, and export/do something with the required values. I don't prefer this, as there will be users using the dashboard at that time, and I don't want to disturb their work.
To give a bit more context, I would like to obtain values/dataframes from several dashboards at a specific time. These values are calculated via a chain of multiple reactives and inputs. I cannot trust that these dashboards are already running, so I need to start them.

Is there a way to moving playhead/current time in After Effects?

In short, I need to reset the playhead back to frame 1 at the time of the script running.
I'm creating a script for exporting a handful comps after updating some text.
One export will be a jpg, and then 2 short videos. I am using app.executeCommand(2104) which is Save Frame As to add the current frame to the render queue for the jpg export. Otherwise, AE would be trying to export a jpg sequence even if only 1 frame long. This affects the output name and the settings of the export. I haven't found an easy way of avoiding the added formatting.
I will be giving this to inexperienced coworkers, who will surely forget to reset the playhead before hitting my export button. So I was trying to force the playhead back to the beginning within the script.
Export Changes
I have tried updating the output render settings with a Time Span Start and Time Span Duration but that changed it back into the jpg sequence.
I thought I could trick/hack it by creating a new comp and then deleting. since when doing it by hand it moves the playhead to zero of the newly created comp. however, when changing focus back to the JPG comp the playhead jumped back to where it was originally.
I have searched through both of the official Adobe guides for scripting and the usual net forums but I haven't found a single command that works for moving the playhead other than by hand. I'm hoping I just missed something obvious.
The playhead-time-thingy-line is called the CTI (Current Time Indicator) in AE-Land. So this should work.
app.project.activeItem.time = 0;
(How) can I move the CTI from within a script?

Optimising Shiny Dashboard plot redraw

I have built a shiny dashboard which has a set of data loaded in as a data frame. It uses dplyr to then select columns, mutate new columns if needed, apply a set of filters and then plot using a variety of high-level ggplot2-based packages.
We try to do the data load, select and mutate just the once. The filtering is sat in a reactive variable, accessed by the plot, and is based upon different input values.
As far as I see this is a pretty standard and typical use case.
I'm wondering whether anyone could advise on workflow patterns to make the output more responsive.
There are two scenarios I encounter with this writing pattern which appear to cause significant user interface delay which I'd like to avoid:
Firstly, when the dashboard first loads it tries to plot the charts using NULL data. I've found I can get around this by using if(is.null(my_data_frame)) and returning geom_blank() rather than our plot. Is there a neater / faster way to do this?
Secondly (and more challengingly): to the right of my plot are a (potentially large) set of filter options to allow the user to analyse subsets. If the user clicks several of these options in rapid succession, Shiny will repeatedly recalculate our reactive() value and replot the chart for each click event: where the user actually just needed to set or clear 5 options. Is there a way to prevent this happening - so if the recalculation isn't complete we don't continue with the plot in progress as we've just made the data stale? Or do you think about grouping options with an update button to prevent this?
In response to your second bullet. Check out shiny's debounce/throttle capabilities. These should slow down the reactive response so your user can finish with the UI control before the chart or presentation element recalculates.
For your first question, try using the req function inside your reactive block. If your plot is waiting on the data frame to load, you can put the code for loading the data frame in a named reactive block (it seems like you may have already done this), then pass that to req. This will prevent the plot from attempting to render until it receives a valid value for whatever you passed to req.
For the second, I'd recommend wrapping your plot render in an observeEvent and having an 'Update' button, if you typically expect users to change multiple options between desired plot updates.
Finally, for added performance, I just saw today that Shiny v1.2.0 has either just been released or is about to be, the major feature of which is plot caching. You can find more details HERE.

R shiny save input of text area globally

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).

Debugging an incorrectly rendered control

I'm trying to debug a weird issue where a control is being rendered with multiple (different) id attributes. I believe something is manually adding the incorrect id, but I'm having issues figuring out when, and myControl.Attributes is empty.
Is it possible to set a breakpoint midway through Page_Render and read what has currently been written to the Output stream?
Note that Response.OutputStream.CanRead is false.
Or better yet, is there a way to view the string that would be rendered by a control at a given point in time?

Resources