0

I'm trying to refresh an Power BI dashboard to capture new data I scrape every hour.

I've tried shell.exec("link") in R to refresh it but it opened a new window. I´d like only to refresh it.

1 Answers1

1

Assuming you're using Windows, one can refresh a page using Shift+F5.

cls <- function () { 
  require(RDCOMClient) 
  wsh <- COMCreate("Wscript.Shell") 
  wsh$SendKeys("+{F5}") 
  invisible(wsh) 
} 
cls()

For more keypresses read here.


Edit - 1 Nov 2019

The problem with the approach mentioned above is that

how do I know which window is active?

, which I could not answer using R.

Instead I suggest a different take using RSelenium with methods navigate and refresh

remDr$navigate("https://...")
remDr$refresh()

If you decide to call a Python or JavaScript script from R to do the dirty work for you, then have a look at the answers to this question which is quite similar to yours and most answers use it to refresh.

Tiago Martins Peres
  • 14,289
  • 18
  • 86
  • 145