I tried the most basic code for leaflet in rstudio:
library(leaflet)
m <- leaflet()
m <- addTiles(m)
m <- addMarkers(m, lng=174.768, lat=-36.852, popup="The birthplace of R")
m
When I run it as a script, nothing happens, the m object is not created, no other errors are given. However, if I run it line by line, it gives the expected output - object m is created and the map is printed.
What can be the problem? ChatGPT could not tell. I reinstalled and updated everything, all libraries and Rstudio itself.
print(m)
to your script.