R wants Rtools installed but install.Rtools() doesn't seem to work

I've been using R for years using the basic interface and decided to try Rstudio. Also updated R from 4.0 to 4.2 Went to install packages in Rstudio and got the message "WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:"
It didn't give any clue how to do that.
I tried from the command line:

install.Rtools(check = TRUE, check_r_update = TRUE)
Error in install.Rtools(check = TRUE, check_r_update = TRUE) :
could not find function "install.Rtools"

so how do I do it? tia.

Go to CRAN, click on Download R for Windows, then Rtools and then RTools 4.2

https://cran.r-project.org/

Just to clarify, this has nothing to do with the RStudio IDE. You need RTools (which is a separate software) to compile R packages from source on Windows systems regardless of the use of any IDE.