removing 'C:/Users/AppData/Local/R/win-library/4.2/sp'
Warning in install.packages :
installation of package ‘C:/users/downloads/sp_1.6-0.tar.gz’ had non-zero exit status
This error message suggests that the system cannot find the gcc compiler, which is needed to build the 'sp' package from source. It is also possible that there is an issue with the path to the compiler specified in the R configuration file (Makeconf).
One solution would be to install the package from a pre-compiled binary instead of building from source. This can be done by using the command install.packages("sp", type = "binary").
Another solution is to check that the gcc compiler is installed on your system and that the path to the compiler is correctly specified in the R configuration file. You can check the path by running the command Sys.getenv("PATH") in R and make sure that the path to the gcc compiler is included. If it is not, you can add the path to the compiler by running Sys.setenv(PATH = paste(Sys.getenv("PATH"), "path/to/gcc", sep = ":")).
If the problem persist, I suggest you to check the version of R, RStudio and the version of gcc. Make sure they are compatible with each other and try again.