(R Shiny) How to use user inputs to dynamically modify reactive value?

shiny

#1

Currently, I'm working on a Shiny app that instructs users to input their CSV file into the web app. The CSV is stored in the server end by a reactive function.

After which, the user has the option to modify the data-set within the web app. For instance, they can change the datatype, remove and impute nulls.

The issue being that I wish to change the reactive variable dynamically as the user selects the various data-set cleansing options. If they choose to just impute nulls, then that is all that should be changed to workingDf(). If they undo or use multiple elements of the cleaning process, then that should accordingly change workingDf() to reflect that. Having attempted eventReactives to directly modify workingDf(), I've come across recursion errors. Like:

Warning: Error in : evaluation nested too deeply: infinite recursion / options(expressions=)?

Any thoughts would be quite helpful. Thank you.

The code is a bit lengthy to post in its entirety, thus I've added a snippet of the UI, showing two potential data cleaning functionalities presented to the user.

Thank you

UI

                 #defines column
             fluidRow(
               column(width = 4,
                      helpText("Change datatype (to numeric or to character): "),

                      #user input: datatype converter
                      radioButtons("dataType", "Data type converter", 
                                   c(toNumeric = 'To Numeric',
                                     toCharacter = 'To Character')
                                   ),

                      #displays that execution of datatype conversion is complete
                      verbatimTextOutput("dataConfirm")

               ),




               column(width = 4, offset = 1,

                      helpText("Select column, then choose cleaning method: "),
                      helpText("Removes all rows with NULLs in column."), 

                      #output of null columns removal, head only, 
                      verbatimTextOutput("nullCount"),
                      verbatimTextOutput("nullCount_2"),

                      #user input: binary for whether to remove nulls
                      checkboxInput("null", "Remove NULLs", FALSE)

               )
             ),


             br(),

             hr(),


             helpText("Impute NULL values in selected column."), 

             #user input: selecting type of null imputation
             radioButtons("null_imp", "Imputation method", 
                          c(Mean = 'mean',
                            Median = 'median',
                            Mode = 'mode')),

             verbatimTextOutput("nullImpute"),

             #user input: execute selected imputation method on selected column
             actionButton("impute", "Impute"),
             verbatimTextOutput("nullImpute_2")

Server

#reactive, CSV input field, stores are variable
workingDf <- reactive({
rawDf <- input$fileIn

req(rawDf)

# if (is.null(rawDf))
#   return(NULL)

lookDf <- read.csv(rawDf$datapath, header = input$header, sep=input$sep)

return(lookDf)

})