Slowing of ggplot2 and plotly

Welcome to!

There are a number of ways you might speed up your code. A good way to get specific advice on this is to provide a reproducible example (what folks usually refer to as a reprex) of your problem, data and code. (And I'd suggest offering a smaller, but representative dataset to start with).

In terms of general strategies to speed up your R-code (or any code for that matter), I would suggest checking out @csgillespie's "Efficient optimisation" chapter from "Efficient R programming". If you can overlook his (British) misspellings of optimisation, there's a wealth of good advice there.

Given the limited info about the issue so far, and just some ideas; I might work through

  • data loading, can you load your data faster? perhaps via a database?
  • are there computationally costly operations that can be avoided or optimized?
  • can you benefit from parallelisation?
  • can you reduce how much data your visualization needs to plot (eg smoothers or densities)?