0

I have some dataframe in Shiny df. df was built by using multiple text inputs. So in order to build df I had to wrap df in a reactive expression since we wanted it to take text inputs. From here I want to run df through a complex engine that was built in R before hand. The engine is not written in reactive programming. Is there anyway I can pass my dataframe to the engine without the need to rewrite the entire engine? My problem right now is that because df is reactive, it seems that it can only be called by other reactive expressions.

I have my initial inputs:

textInput("value1", "Variable 1"),
textInput("value2", "Variable 2"),
textInput("value3", "Variable 3")

Which creates this data frame

 newdataframe<-eventReactive(input$save_data, {
    saveddataframe<-data.frame(
      name=c("Q", "EBED", "L"),
      value=c(input$value1, input$value2, input$value3),
      )
    saveddataframe
  })

The way the engine usually calls the data it needs is

newdataframe <- read_excel(in_file_name, sheet = "params")

but I can't do something as simple as this anymore because I'm not directly reading in an excel file to get my dataframe. I'm getting my dataframe by creating it with reactive expressions. It seems like there should be some way to access the data in the dataframe without having to rewrite the engine. So I can't access the data with standard R commands which seems like there should exist some way around this.

David_Cola
  • 21
  • 5
  • It's easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. How exactly are you currently passing your data from shiny to your "engine"? – MrFlick Jul 14 '22 at 12:57
  • Can you not simply copy the current state of the reactive dataframe into a non reactive dataframe and then pass that into your complex engine? Besides I doubt that "I had to wrap df in a reactive expression since we wanted it to take text inputs" is true. – Limey Jul 14 '22 at 13:14
  • 1
    It's still not exactly clear when/how you are calling the engine. You get the current value of a reactive value just by calling it like a function. `newdataframe()` will return a normal data.frame as long as you call it from a reactive environment. You can then pass that value on to whatever non-reactive functions you want. – MrFlick Jul 14 '22 at 13:43

0 Answers0