It is possible that you attempted to install one or both of R or RStudio from source, rather than as a binary object. Anything involving macOS and compilation from source is doubtful due to Apple's non-standard compiler chain. Without advanced expertise, any time that an installation of software from source, generally, or an R package, specifically, fails, it is best to seek a precompiled binary, especially on the new M1 chipset.
Therefore, do not attempt to install R-4.1.0.tar.gz from CRAN. Instead install the dmg binary for Intel or the M1 version. If, however, R works from the terminal command line,
$ R
and it returns a splash page and then the prompt
>
you do not need to reinstall.
If you do install from the dmg, take the option to install for all users and enter an admin password.
For RStudio, install the dmg file.
Once R is working from RStudio, when installing packages you will often be presented with a message to the effect that
a binary version is available, but the source version is later
and it costs only a little trouble to try. If it does not work the first time, it will not work subsequently without more time, trouble and effort than anyone who is not a highly evolved expert would care to use, as it rerquires editing source code.
As much as I enjoyed macOS over the years, the issues around compilation of R and other open source libraries drove me to Ubuntu, where I have no problems of this sort.