Reactive data frame?

1,295 views
Skip to first unread message

Jeremiah Coleman

unread,
Dec 11, 2012, 8:38:40 AM12/11/12
to shiny-...@googlegroups.com
Here's a tricky one I haven't seen asked yet. Is there a way to create a reactive data frame? I'm building an app to do analyses on data from Clinicaltrials.gov - I'll have a sidebar which is basically the search engine. Hitting "submit" downloads a set of XML files matching the search criteria. The problem is, sometimes this can take a few minutes. I would like to be able to create one data frame from this data which I can use in my analyses, and it will only update when the search is changed. Any ideas?

Joe Cheng

unread,
Dec 11, 2012, 12:18:00 PM12/11/12
to shiny-...@googlegroups.com
You really mean "it will only update when the search button is clicked", don't you?

Besides the search criteria, are there other input controls on the page that will be used to customize the analyses?


On Tue, Dec 11, 2012 at 5:38 AM, Jeremiah Coleman <colem...@gmail.com> wrote:
Here's a tricky one I haven't seen asked yet. Is there a way to create a reactive data frame? I'm building an app to do analyses on data from Clinicaltrials.gov - I'll have a sidebar which is basically the search engine. Hitting "submit" downloads a set of XML files matching the search criteria. The problem is, sometimes this can take a few minutes. I would like to be able to create one data frame from this data which I can use in my analyses, and it will only update when the search is changed. Any ideas?

--
 
 

Jeremiah Coleman

unread,
Dec 11, 2012, 2:14:13 PM12/11/12
to shiny-...@googlegroups.com
Yes, that's a much better way of saying it.

There will be several additional controls on the page - the main one allowing the user to choose specifically which records in the data to use.

Winston Chang

unread,
Dec 11, 2012, 4:38:50 PM12/11/12
to shiny-...@googlegroups.com
Assuming you have a separate reactive function for retrieving the
data, you could do something roughly like this:

# Holds the downloaded data
df1 <- reactive(function() {
# Download and load the XML data
...
}

# Gets a subset based on user controls
df2 <- reactive(function() {
# Return a subset of df1(). For example, suppose min_age is
controlled by the user:
subset(df1(), age >= input$min_age)
}

output$myplot <- reactivePlot(reactivePlot(function() {
# Make the plot
...
}


-Winston
> --
>
>

Jeremiah Coleman

unread,
Dec 12, 2012, 6:56:21 AM12/12/12
to shiny-...@googlegroups.com, win...@rstudio.com
Nice! Didn't realize it would be this easy.

cea...@gmail.com

unread,
Dec 13, 2013, 9:51:43 AM12/13/13
to shiny-...@googlegroups.com, win...@rstudio.com
Hi, I'm facing the same problem but this code is not working in my case. I want to subset by date range, using dateInput to obtain start and end of the data period.

You can see my code at a StackOverflow post. http://stackoverflow.com/q/20566204/709777

Thanks in advance
Reply all
Reply to author
Forward
0 new messages