Stack Overflow user hrbrmstr solved this problem. Here I share the solution below:
Try adding both the R executable and RStudio executable (drag their icons) to the Full Disk Access element under the Privacy tab of System Preferences => Security & Privacy.