Isolate list of reactive data.frames in ShinyRemove rows with all or some NAs (missing values) in data.frameR shiny passing reactive to selectInput choicesRShiny - overly reactive outputUse a reactive dataframe in Shiny to predict(svm)R shiny isolate reactive data.frameR Creating Dynamic variables from group aggregated set of DataFramesHow to store reactive outputs values in a vector to be used in a function?R shiny modify a specific element in a reactive tableUsing a function with an reactive argument for generating a tablePopulate dynamic table in with predicted values in shiny R
I unknowingly submitted plagarised work
Employer asking for online access to bank account - Is this a scam?
Why do airplanes use an axial flow jet engine instead of a more compact centrifugal jet engine?
Make 24 using exactly three 3s
Is it rude to call a professor by their last name with no prefix in a non-academic setting?
Where have Brexit voters gone?
What is quasi-aromaticity?
How to use Palladio font in text body but Computer Modern for Equations?
Line of lights moving in a straight line , with a few following
Is CD audio quality good enough?
Python program to find the most frequent letter in a text
How can I tell if I'm being too picky as a referee?
Why did David Cameron offer a referendum on the European Union?
What is the object moving across the ceiling in this stock footage?
Is the Indo-European language family made up?
At what point in European history could a government build a printing press given a basic description?
Could a 19.25mm revolver actually exist?
Would Brexit have gone ahead by now if Gina Miller had not forced the Government to involve Parliament?
Simple function that simulates survey results based on sample size and probability
Have 1.5% of all nuclear reactors ever built melted down?
Adding spaces to string based on list
Why is this Simple Puzzle impossible to solve?
Why aren't space telescopes put in GEO?
Who will lead the country until there is a new Tory leader?
Isolate list of reactive data.frames in Shiny
Remove rows with all or some NAs (missing values) in data.frameR shiny passing reactive to selectInput choicesRShiny - overly reactive outputUse a reactive dataframe in Shiny to predict(svm)R shiny isolate reactive data.frameR Creating Dynamic variables from group aggregated set of DataFramesHow to store reactive outputs values in a vector to be used in a function?R shiny modify a specific element in a reactive tableUsing a function with an reactive argument for generating a tablePopulate dynamic table in with predicted values in shiny R
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm using shiny to create a list of reactive data.frames that I want to pass into a function. The function works well with lists of non-reactive data.frames, but I cannot figure out how to either 1) isolate the list of reactive data.frames just before passing it into the function, or 2) pass it into the function and then isolate the data.frames inside the function. The output of this function will be downloaded from shiny app, not rendered to output.
non_reactive_df_list <- isolate(df_list()) #throws error because the list isn't reactive, just the dataframes (df_list[[i]]) are reactive
non_reactive_df_list <- map(df_list, isolate) #doesn't work, and even it if did, there is no trigger/actionButton
What I really want would be like ..
df_list <- eventIsolateListElements(input$actionButton, df_list) # where df_list contains reactive elements
I don't know how many dfs there will be in the list.
The function I'm using:
dfList2string <- function(dbList)
string <- "**DataFrame String**"
for (i in seq_along(dbList))
string <- paste(string, names(dbList[i]), sep = 'nn')
sub_string <- paste(names(dbList[[i]]), collapse = ', ')
string <- paste(string, sub_string, sep = 'n')
for (j in seq(1:nrow(dbList[[i]])))
sub_string <- paste(dbList[[i]][j,], collapse = ', ' )
string <- paste(string, sub_string, sep = 'n')
return(string)
if you want a shiny app example, I made a small shiny app that describes what I want. I do not include the code that doesn't work because it just crashes (makes troubleshooting difficult)
require(shiny)
#make list of two non-reactive dataframes
dfList <- list()
dfList$df1 <- data.frame(a = rnorm(5, 1),
b = rnorm(5, 1))
dfList$df2 <- data.frame(a = rnorm(5, 3),
b = rnorm(5, 3))
ui <- fluidPage(
fluidRow(
HTML('<h3>User Inputs</h3>'),
numericInput('dfmean1', 'select mean df1', value= 1), #user choose mean for df1
numericInput('dfmean2', 'select mean df2', value= 2), #user choose mean for df2
HTML('<h3>Reactive df1</h3>'),
tableOutput('reactive_table1'), #show reactive df1 table for clarity
HTML('<h3>Reactive df2</h3>'),
tableOutput('reactive_table2'), #show reactive df2 table for clarity
HTML('<h3>Button to trigger Isolation of reactive list of df1 and df2</h3>'),
actionButton('action', 'WriteToText'), #this button should trigger the conversion of reactive_dfList to text string
HTML('<h3>Example function output using normal list of non-reactive dfs </h3>'),
verbatimTextOutput('text_table') #this shows output of a function that converts non-reactive dfList to text string
)
)
server <- function(session, input, output)
#make list of two reactive dataframes
reactive_dfList <- list() #initiate list to contain the two reactive dfs 1 and 2
reactive_dfList$df1 <- reactive(
data.frame(a = rnorm(5, input$dfmean1),
b = rnorm(5, input$dfmean1))
)
reactive_dfList$df2 <- reactive(
data.frame(a = rnorm(5, input$dfmean2),
b = rnorm(5, input$dfmean2))
)
#view the tables of reactive dataframs for clarity
output$reactive_table1 <- renderTable( reactive_dfList$df1() )
output$reactive_table2 <- renderTable( reactive_dfList$df2() )
#function that converts list of dfs to a text string
dfList2string <- function(dbList)
string <- "**DataFrame String**"
for (i in seq_along(dbList))
string <- paste(string, names(dbList[i]), sep = 'nn')
sub_string <- paste(names(dbList[[i]]), collapse = ', ')
string <- paste(string, sub_string, sep = 'n')
for (j in seq(1:nrow(dbList[[i]])))
sub_string <- paste(dbList[[i]][j,], collapse = ', ' )
string <- paste(string, sub_string, sep = 'n')
return(string)
output$text_table <- renderText(
dfList2string(dfList)
)
shinyApp(ui, server)
r shiny shiny-reactivity
add a comment |
I'm using shiny to create a list of reactive data.frames that I want to pass into a function. The function works well with lists of non-reactive data.frames, but I cannot figure out how to either 1) isolate the list of reactive data.frames just before passing it into the function, or 2) pass it into the function and then isolate the data.frames inside the function. The output of this function will be downloaded from shiny app, not rendered to output.
non_reactive_df_list <- isolate(df_list()) #throws error because the list isn't reactive, just the dataframes (df_list[[i]]) are reactive
non_reactive_df_list <- map(df_list, isolate) #doesn't work, and even it if did, there is no trigger/actionButton
What I really want would be like ..
df_list <- eventIsolateListElements(input$actionButton, df_list) # where df_list contains reactive elements
I don't know how many dfs there will be in the list.
The function I'm using:
dfList2string <- function(dbList)
string <- "**DataFrame String**"
for (i in seq_along(dbList))
string <- paste(string, names(dbList[i]), sep = 'nn')
sub_string <- paste(names(dbList[[i]]), collapse = ', ')
string <- paste(string, sub_string, sep = 'n')
for (j in seq(1:nrow(dbList[[i]])))
sub_string <- paste(dbList[[i]][j,], collapse = ', ' )
string <- paste(string, sub_string, sep = 'n')
return(string)
if you want a shiny app example, I made a small shiny app that describes what I want. I do not include the code that doesn't work because it just crashes (makes troubleshooting difficult)
require(shiny)
#make list of two non-reactive dataframes
dfList <- list()
dfList$df1 <- data.frame(a = rnorm(5, 1),
b = rnorm(5, 1))
dfList$df2 <- data.frame(a = rnorm(5, 3),
b = rnorm(5, 3))
ui <- fluidPage(
fluidRow(
HTML('<h3>User Inputs</h3>'),
numericInput('dfmean1', 'select mean df1', value= 1), #user choose mean for df1
numericInput('dfmean2', 'select mean df2', value= 2), #user choose mean for df2
HTML('<h3>Reactive df1</h3>'),
tableOutput('reactive_table1'), #show reactive df1 table for clarity
HTML('<h3>Reactive df2</h3>'),
tableOutput('reactive_table2'), #show reactive df2 table for clarity
HTML('<h3>Button to trigger Isolation of reactive list of df1 and df2</h3>'),
actionButton('action', 'WriteToText'), #this button should trigger the conversion of reactive_dfList to text string
HTML('<h3>Example function output using normal list of non-reactive dfs </h3>'),
verbatimTextOutput('text_table') #this shows output of a function that converts non-reactive dfList to text string
)
)
server <- function(session, input, output)
#make list of two reactive dataframes
reactive_dfList <- list() #initiate list to contain the two reactive dfs 1 and 2
reactive_dfList$df1 <- reactive(
data.frame(a = rnorm(5, input$dfmean1),
b = rnorm(5, input$dfmean1))
)
reactive_dfList$df2 <- reactive(
data.frame(a = rnorm(5, input$dfmean2),
b = rnorm(5, input$dfmean2))
)
#view the tables of reactive dataframs for clarity
output$reactive_table1 <- renderTable( reactive_dfList$df1() )
output$reactive_table2 <- renderTable( reactive_dfList$df2() )
#function that converts list of dfs to a text string
dfList2string <- function(dbList)
string <- "**DataFrame String**"
for (i in seq_along(dbList))
string <- paste(string, names(dbList[i]), sep = 'nn')
sub_string <- paste(names(dbList[[i]]), collapse = ', ')
string <- paste(string, sub_string, sep = 'n')
for (j in seq(1:nrow(dbList[[i]])))
sub_string <- paste(dbList[[i]][j,], collapse = ', ' )
string <- paste(string, sub_string, sep = 'n')
return(string)
output$text_table <- renderText(
dfList2string(dfList)
)
shinyApp(ui, server)
r shiny shiny-reactivity
shiny.rstudio.com/articles/debugging.html Maybe this can help you debug shiny app.
– noob
Mar 24 at 6:41
I don't understand what you want to achieve. Please share the code that crashes, I can try to debug. In general you just do isolate(reactiveVar()) and everything works.
– Alexander Leow
Mar 24 at 17:20
Thank you for your suggestions @AlexanderLeow, I will try isolate(reactiveVar(reactiveDF)) when I get back to the office. Maybe I could create actionButton dependency inside the call to isolate, since making the dependency outside the call to isolate will re-create reactivity.
– NicoWheat
Mar 28 at 19:40
add a comment |
I'm using shiny to create a list of reactive data.frames that I want to pass into a function. The function works well with lists of non-reactive data.frames, but I cannot figure out how to either 1) isolate the list of reactive data.frames just before passing it into the function, or 2) pass it into the function and then isolate the data.frames inside the function. The output of this function will be downloaded from shiny app, not rendered to output.
non_reactive_df_list <- isolate(df_list()) #throws error because the list isn't reactive, just the dataframes (df_list[[i]]) are reactive
non_reactive_df_list <- map(df_list, isolate) #doesn't work, and even it if did, there is no trigger/actionButton
What I really want would be like ..
df_list <- eventIsolateListElements(input$actionButton, df_list) # where df_list contains reactive elements
I don't know how many dfs there will be in the list.
The function I'm using:
dfList2string <- function(dbList)
string <- "**DataFrame String**"
for (i in seq_along(dbList))
string <- paste(string, names(dbList[i]), sep = 'nn')
sub_string <- paste(names(dbList[[i]]), collapse = ', ')
string <- paste(string, sub_string, sep = 'n')
for (j in seq(1:nrow(dbList[[i]])))
sub_string <- paste(dbList[[i]][j,], collapse = ', ' )
string <- paste(string, sub_string, sep = 'n')
return(string)
if you want a shiny app example, I made a small shiny app that describes what I want. I do not include the code that doesn't work because it just crashes (makes troubleshooting difficult)
require(shiny)
#make list of two non-reactive dataframes
dfList <- list()
dfList$df1 <- data.frame(a = rnorm(5, 1),
b = rnorm(5, 1))
dfList$df2 <- data.frame(a = rnorm(5, 3),
b = rnorm(5, 3))
ui <- fluidPage(
fluidRow(
HTML('<h3>User Inputs</h3>'),
numericInput('dfmean1', 'select mean df1', value= 1), #user choose mean for df1
numericInput('dfmean2', 'select mean df2', value= 2), #user choose mean for df2
HTML('<h3>Reactive df1</h3>'),
tableOutput('reactive_table1'), #show reactive df1 table for clarity
HTML('<h3>Reactive df2</h3>'),
tableOutput('reactive_table2'), #show reactive df2 table for clarity
HTML('<h3>Button to trigger Isolation of reactive list of df1 and df2</h3>'),
actionButton('action', 'WriteToText'), #this button should trigger the conversion of reactive_dfList to text string
HTML('<h3>Example function output using normal list of non-reactive dfs </h3>'),
verbatimTextOutput('text_table') #this shows output of a function that converts non-reactive dfList to text string
)
)
server <- function(session, input, output)
#make list of two reactive dataframes
reactive_dfList <- list() #initiate list to contain the two reactive dfs 1 and 2
reactive_dfList$df1 <- reactive(
data.frame(a = rnorm(5, input$dfmean1),
b = rnorm(5, input$dfmean1))
)
reactive_dfList$df2 <- reactive(
data.frame(a = rnorm(5, input$dfmean2),
b = rnorm(5, input$dfmean2))
)
#view the tables of reactive dataframs for clarity
output$reactive_table1 <- renderTable( reactive_dfList$df1() )
output$reactive_table2 <- renderTable( reactive_dfList$df2() )
#function that converts list of dfs to a text string
dfList2string <- function(dbList)
string <- "**DataFrame String**"
for (i in seq_along(dbList))
string <- paste(string, names(dbList[i]), sep = 'nn')
sub_string <- paste(names(dbList[[i]]), collapse = ', ')
string <- paste(string, sub_string, sep = 'n')
for (j in seq(1:nrow(dbList[[i]])))
sub_string <- paste(dbList[[i]][j,], collapse = ', ' )
string <- paste(string, sub_string, sep = 'n')
return(string)
output$text_table <- renderText(
dfList2string(dfList)
)
shinyApp(ui, server)
r shiny shiny-reactivity
I'm using shiny to create a list of reactive data.frames that I want to pass into a function. The function works well with lists of non-reactive data.frames, but I cannot figure out how to either 1) isolate the list of reactive data.frames just before passing it into the function, or 2) pass it into the function and then isolate the data.frames inside the function. The output of this function will be downloaded from shiny app, not rendered to output.
non_reactive_df_list <- isolate(df_list()) #throws error because the list isn't reactive, just the dataframes (df_list[[i]]) are reactive
non_reactive_df_list <- map(df_list, isolate) #doesn't work, and even it if did, there is no trigger/actionButton
What I really want would be like ..
df_list <- eventIsolateListElements(input$actionButton, df_list) # where df_list contains reactive elements
I don't know how many dfs there will be in the list.
The function I'm using:
dfList2string <- function(dbList)
string <- "**DataFrame String**"
for (i in seq_along(dbList))
string <- paste(string, names(dbList[i]), sep = 'nn')
sub_string <- paste(names(dbList[[i]]), collapse = ', ')
string <- paste(string, sub_string, sep = 'n')
for (j in seq(1:nrow(dbList[[i]])))
sub_string <- paste(dbList[[i]][j,], collapse = ', ' )
string <- paste(string, sub_string, sep = 'n')
return(string)
if you want a shiny app example, I made a small shiny app that describes what I want. I do not include the code that doesn't work because it just crashes (makes troubleshooting difficult)
require(shiny)
#make list of two non-reactive dataframes
dfList <- list()
dfList$df1 <- data.frame(a = rnorm(5, 1),
b = rnorm(5, 1))
dfList$df2 <- data.frame(a = rnorm(5, 3),
b = rnorm(5, 3))
ui <- fluidPage(
fluidRow(
HTML('<h3>User Inputs</h3>'),
numericInput('dfmean1', 'select mean df1', value= 1), #user choose mean for df1
numericInput('dfmean2', 'select mean df2', value= 2), #user choose mean for df2
HTML('<h3>Reactive df1</h3>'),
tableOutput('reactive_table1'), #show reactive df1 table for clarity
HTML('<h3>Reactive df2</h3>'),
tableOutput('reactive_table2'), #show reactive df2 table for clarity
HTML('<h3>Button to trigger Isolation of reactive list of df1 and df2</h3>'),
actionButton('action', 'WriteToText'), #this button should trigger the conversion of reactive_dfList to text string
HTML('<h3>Example function output using normal list of non-reactive dfs </h3>'),
verbatimTextOutput('text_table') #this shows output of a function that converts non-reactive dfList to text string
)
)
server <- function(session, input, output)
#make list of two reactive dataframes
reactive_dfList <- list() #initiate list to contain the two reactive dfs 1 and 2
reactive_dfList$df1 <- reactive(
data.frame(a = rnorm(5, input$dfmean1),
b = rnorm(5, input$dfmean1))
)
reactive_dfList$df2 <- reactive(
data.frame(a = rnorm(5, input$dfmean2),
b = rnorm(5, input$dfmean2))
)
#view the tables of reactive dataframs for clarity
output$reactive_table1 <- renderTable( reactive_dfList$df1() )
output$reactive_table2 <- renderTable( reactive_dfList$df2() )
#function that converts list of dfs to a text string
dfList2string <- function(dbList)
string <- "**DataFrame String**"
for (i in seq_along(dbList))
string <- paste(string, names(dbList[i]), sep = 'nn')
sub_string <- paste(names(dbList[[i]]), collapse = ', ')
string <- paste(string, sub_string, sep = 'n')
for (j in seq(1:nrow(dbList[[i]])))
sub_string <- paste(dbList[[i]][j,], collapse = ', ' )
string <- paste(string, sub_string, sep = 'n')
return(string)
output$text_table <- renderText(
dfList2string(dfList)
)
shinyApp(ui, server)
r shiny shiny-reactivity
r shiny shiny-reactivity
asked Mar 24 at 5:28
NicoWheatNicoWheat
67688
67688
shiny.rstudio.com/articles/debugging.html Maybe this can help you debug shiny app.
– noob
Mar 24 at 6:41
I don't understand what you want to achieve. Please share the code that crashes, I can try to debug. In general you just do isolate(reactiveVar()) and everything works.
– Alexander Leow
Mar 24 at 17:20
Thank you for your suggestions @AlexanderLeow, I will try isolate(reactiveVar(reactiveDF)) when I get back to the office. Maybe I could create actionButton dependency inside the call to isolate, since making the dependency outside the call to isolate will re-create reactivity.
– NicoWheat
Mar 28 at 19:40
add a comment |
shiny.rstudio.com/articles/debugging.html Maybe this can help you debug shiny app.
– noob
Mar 24 at 6:41
I don't understand what you want to achieve. Please share the code that crashes, I can try to debug. In general you just do isolate(reactiveVar()) and everything works.
– Alexander Leow
Mar 24 at 17:20
Thank you for your suggestions @AlexanderLeow, I will try isolate(reactiveVar(reactiveDF)) when I get back to the office. Maybe I could create actionButton dependency inside the call to isolate, since making the dependency outside the call to isolate will re-create reactivity.
– NicoWheat
Mar 28 at 19:40
shiny.rstudio.com/articles/debugging.html Maybe this can help you debug shiny app.
– noob
Mar 24 at 6:41
shiny.rstudio.com/articles/debugging.html Maybe this can help you debug shiny app.
– noob
Mar 24 at 6:41
I don't understand what you want to achieve. Please share the code that crashes, I can try to debug. In general you just do isolate(reactiveVar()) and everything works.
– Alexander Leow
Mar 24 at 17:20
I don't understand what you want to achieve. Please share the code that crashes, I can try to debug. In general you just do isolate(reactiveVar()) and everything works.
– Alexander Leow
Mar 24 at 17:20
Thank you for your suggestions @AlexanderLeow, I will try isolate(reactiveVar(reactiveDF)) when I get back to the office. Maybe I could create actionButton dependency inside the call to isolate, since making the dependency outside the call to isolate will re-create reactivity.
– NicoWheat
Mar 28 at 19:40
Thank you for your suggestions @AlexanderLeow, I will try isolate(reactiveVar(reactiveDF)) when I get back to the office. Maybe I could create actionButton dependency inside the call to isolate, since making the dependency outside the call to isolate will re-create reactivity.
– NicoWheat
Mar 28 at 19:40
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55320988%2fisolate-list-of-reactive-data-frames-in-shiny%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55320988%2fisolate-list-of-reactive-data-frames-in-shiny%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
shiny.rstudio.com/articles/debugging.html Maybe this can help you debug shiny app.
– noob
Mar 24 at 6:41
I don't understand what you want to achieve. Please share the code that crashes, I can try to debug. In general you just do isolate(reactiveVar()) and everything works.
– Alexander Leow
Mar 24 at 17:20
Thank you for your suggestions @AlexanderLeow, I will try isolate(reactiveVar(reactiveDF)) when I get back to the office. Maybe I could create actionButton dependency inside the call to isolate, since making the dependency outside the call to isolate will re-create reactivity.
– NicoWheat
Mar 28 at 19:40