Disabling RStudio real-time diagnostics can solve some speed issues/freezing when working with very large R files, or files that are located on the network storage units or accessed over VPNs. (Unless using an older version of R/RStudio for a particular reason, check that you are using the latest version of R and RStudio under the Help tab).
First, open RStudio and open the Tools tab. Click on Global Options...
Next, under the Options menu, open the Code options and click the Diagnostics tab. Under R Diagnostics, uncheck the Show diagnostics for R box. Once finished, make sure to Apply.
Finally, close R/RStudio and run the app again. Repeat the steps above to confirm that Show Diagnostics is still unchecked. You can now try rerunning your R code to check for any improvement in run time.