Beginner is here, please be gentle 
The following code produces no plotly charts in the Viewer window if I run it from an R-file script. The same code copy&pasted into the Console window, shows chart in the Viewer as it should.
Any help will be greatly appreciated.
library(plotly)
x <- c(1:100)
random_y <- rnorm(100, mean = 0)
data <- data.frame(x, random_y)
fig <- plot_ly(data, x = ~x, y = ~random_y, type = 'scatter', mode = 'lines')
fig
I tried reinstalling all from scratch, no difference.
RStudio ver: Win Desktop 1.2.5033
R ver: 3.6.3
Plotly ver: 4.9.2