Converting Data read from reactiveFileReader() to normal Dataframe

Hello,

I have used reactiveFileReader() function to read the file updates every 30 seconds. I am not able to do normal manipulation on this read data as its reactive. How can I convert it into a normal Data Frame so that I can use usual R code to slice and dice the data?

Thanks.

I'm not sure I understood the question correctly, but you can call parts of a reactive dataframe by adding the square brackets part after the round ones. df()[ ... , ... ]

For instance if you want to show only the first 3 rows of a file called 'data.csv':

ui <- fluidPage(
  tableOutput("data")
)

server <- function(input, output, session) {

  fileData <- reactiveFileReader(30000, session, 'data.csv', read.csv2)
  
  output$data <- renderTable({
    fileData()[1:3,]
    
  })
}

shinyApp(ui = ui, server = server)

if you would convert it to a normal dataframe there is no point in using reactiveFileReader I guess...

but you could send the data out of the reactive dataframe to the global environment with <<-
For istance, show first 3 rows in panel, save first colum in global environment:

output$data <- renderTable({
    send_to_global <<- fileData()[,1]
    return(fileData()[1:3,])
  })

Hope this is useful

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.