Reputation: 1162
I need to work with very large files (over a million rows) in R Shiny, if possible. It's not the data analytics that's the issue - it's figuring out how to display that much data in a reasonable amount of time - and more importantly, being able to interact with it through a range slider and data selection tools (lasso, point selections). Before I go too much further with my project, I just have a general question about the feasibility of this and would like people's thoughts. Basically, am I wasting my time on this?
I don't really need to display all the data at once (through time series plots), but it would be nice if that's possible. If I could get the range slider to work faster, that would be huge. I have not run across code that shows performance optimization for this type of thing, but it may be out there.
Anyway, if someone has thoughts on how to do this, or can point me in a direction to follow, that would be wonderful. Thank you!
Upvotes: 5
Views: 1783
Reputation: 19544
Plotly loads all the data for the plot in the browser, so number of points usable in the graphics mainly depends on the client-side computer's performance and its bandwidth with the server. On my config, 1M point is a little slow to load (10s) but works OK afterwards.
You can check on your config with this little app:
library(shiny)
library(plotly)
shinyApp(
ui = shinyUI(fluidPage(
titlePanel("Plotly test"),
sidebarLayout(sidebarPanel(
selectInput(
"nb",
"Number of points",
choices = c(
"1K" = 1000,
"10K" = 10000,
"100K" = 100000,
"1M" = 1000000,
"10M" = 10000000
)
)
),
mainPanel(plotlyOutput("plot")))
)),
server = function(input, output, session) {
output$plot <- renderPlotly(plot_ly(
data.frame(x = 1:input$nb,
y = rnorm(input$nb)),
x = ~ x,
y = ~ y
) %>%
add_lines())
}
)
Upvotes: 1