There are ways to do this directly in R, but I find that when I want my R scripts ran regularly I either use GitHub Actions for running in the cloud (configured by YAML), or I will set crontabs on my local Machine (Mac).
There are R packages that support setting cron jobs, such as {cronR}, but I have not used it myself. Do you want this to run on your local machine? For example, I have have it automated so my computer wakes up at 2:55AM every day, then crontabs runs my script to update any out-of-date R packages.