Reputation: 513
I would like your help to access the result elements that the reactiveFileReader function offers me, in which case the result is fileData ()
The server code is this:
server <- function(input, output,session) {
fileData <- reactiveFileReader(1000,session,filePath = 'ddeLink.xlsm', readFunc = read_excel)
output$data <- renderTable({
fileData()
})
}
The excel spreadsheet linkdde.xslm
every five minutes updates. It is composed of 2 columns where only column b is updated. The excel file bellow:
The code works fine. That is, whenever the excel spreadsheet updates my app Shiny also updates the mmatrix above, which is the fileData ()
result.
The fileData()
is always updating. The fileData()
is the matrix above.
But my question is: How do I access the values of this mtrix, represented by the fileData ()
to create a plot that would be updated because the fileData ()
is updating. In other words I want to have a plot updating every 5 minutes using the 5 minutes fileData ()
matrix?
I did this:
output$data <- renderPlot({
df<-as.data.frame(fileData())
plot(df[,1])
})
But it didnt work.
Any help guys
Many thanks
Upvotes: 2
Views: 1178
Reputation: 30474
The below example seems to work, where the plot is updated when the Excel file is updated. Is this what you are looking for? If not, please describe further what you need.
library(shiny)
library(readxl)
ui <- fluidPage(
mainPanel(
uiOutput("data"),
plotOutput("plot")
)
)
server <- function(input, output,session) {
fileData <- reactiveFileReader(1000,
session,
filePath = 'ddeLink.xlsx',
readFunc = read_excel)
output$data <- renderTable({
fileData()
})
output$plot <- renderPlot({
df<-as.data.frame(fileData())
plot(df[,2])
})
}
shinyApp(ui, server)
Upvotes: 2