Hello,
I am new to using the "shiny app" features within R, and have hit a wall in my attempt to access a portion of a data frame. When I try to display the data using the DT::renderDataTable() feature I get the output "Error: 'data' must be 2-dimensional (e.g. data frame or matrix)"
In the code snippet below I am attempting to create a data frame from a range of rows and columns from a larger data frame based on user input. The code works beautifully when I have hard coded integers into the snippet, and only malfunctions when I have inserted variables into the function call. Despite my numerous attempts to overcome, the problem persists. This snippet is located within the server part of my shiny source code.
Code that doesn't work:
smaller_table <- larger_table[c(input$var_1:input$var_2),c(input$var_3:input$var_4)]
Code that does work:
smaller_table <- larger_table[c(1:7),c(1:2)]
based on the fact that the application works when there are ints hard-coded into the line I am assuming is has something to do with the way input$foo is being processed, but I have tried storing them in other variables to access, transforming them with as.numeric(input$foo) and several other approaches. I need the application to allow the user to specify the start/ end of the rows and columns, so this step is integral.
If I have formatted this question incorrectly please let me know, and I would be happy to edit/ delete/ resubmit accordingly.
Thanks in advance,
Chris