Problem with package installation in Rstudio

i am running Rstudio on win 11. I am a biginner user. the works fine other than installing important packages during statistical course excercise. Especially i could not install packages such as "mice" and "ggcorrplot"
this is what i got for "mice" when i tried to install it

WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

RTools: Toolchains for building R and R packages from source on Windows
Installing package into ‘D:/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
also installing the dependencies ‘bit’, ‘bit64’, ‘minqa’, ‘nloptr’, ‘ucminf’, ‘vroom’, ‘tzdb’, ‘lme4’, ‘ordinal’, ‘forcats’, ‘readr’, ‘pillar’, ‘tibble’, ‘glue’, ‘stringi’, ‘RcppEigen’, ‘pan’, ‘jomo’, ‘haven’, ‘cli’, ‘dplyr’, ‘lifecycle’, ‘purrr’, ‘rlang’, ‘stringr’, ‘tidyselect’, ‘vctrs’, ‘broom’, ‘glmnet’, ‘mitml’, ‘tidyr’

Warning in install.packages :

  • unable to access index for repository http://cran.rstudio.com/bin/windows/contrib/3.6:*
  • cannot open URL 'http://cran.rstudio.com/bin/windows/contrib/3.6/PACKAGES'*
    Packages which are only available in source form, and may need
  • compilation of C/C++/Fortran: ‘bit’ ‘bit64’ ‘minqa’ ‘nloptr’ ‘ucminf’*
  • ‘vroom’ ‘tzdb’ ‘lme4’ ‘ordinal’ ‘readr’ ‘tibble’ ‘glue’ ‘stringi’*
  • ‘RcppEigen’ ‘pan’ ‘jomo’ ‘haven’ ‘cli’ ‘dplyr’ ‘purrr’ ‘rlang’*
  • ‘tidyselect’ ‘vctrs’ ‘glmnet’ ‘tidyr’ ‘mice’*
  • These will not be installed*
    installing the source packages ‘forcats’, ‘pillar’, ‘lifecycle’, ‘stringr’, ‘broom’, ‘mitml’

Content type 'application/x-gzip' length 444528 bytes (434 KB)
downloaded 434 KB

Content type 'application/x-gzip' length 107656 bytes (105 KB)
downloaded 105 KB

Content type 'application/x-gzip' length 176599 bytes (172 KB)
downloaded 172 KB

Content type 'application/x-gzip' length 644384 bytes (629 KB)
downloaded 629 KB

Content type 'application/x-gzip' length 223835 bytes (218 KB)
downloaded 218 KB

** installing source package 'lifecycle' ...*
*** package 'lifecycle' successfully unpacked and MD5 sums checked*
*** using staged installation*
*** R*
*** inst*
*** byte-compile and prepare package for lazy loading*
*Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : *

  • namespace 'rlang' 0.4.7 is being loaded, but >= 1.1.0 is required*
    Calls: ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace
    Execution halted
    ERROR: lazy loading failed for package 'lifecycle'
    ** removing 'D:/Documents/R/win-library/3.6/lifecycle'*
    ** restoring previous 'D:/Documents/R/win-library/3.6/lifecycle'*
    Warning in install.packages :
  • installation of package ‘lifecycle’ had non-zero exit status*
    ERROR: dependencies 'pan', 'jomo', 'haven' are not available for package 'mitml'
    ** removing 'D:/Documents/R/win-library/3.6/mitml'*
    Warning in install.packages :
  • installation of package ‘mitml’ had non-zero exit status*
    ** installing source package 'forcats' ...*
    *** package 'forcats' successfully unpacked and MD5 sums checked*
    *** using staged installation*
    *** R*
    *** data*
    **** moving datasets to lazyload DB*
    *** inst*
    *** byte-compile and prepare package for lazy loading*
    *Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : *
  • namespace 'rlang' 0.4.7 is being loaded, but >= 1.0.0 is required*
    Calls: ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace
    Execution halted
    ERROR: lazy loading failed for package 'forcats'
    ** removing 'D:/Documents/R/win-library/3.6/forcats'*
    Warning in install.packages :
  • installation of package ‘forcats’ had non-zero exit status*
    ** installing source package 'pillar' ...*
    *** package 'pillar' successfully unpacked and MD5 sums checked*
    *** using staged installation*
    *** R*
    *** inst*
    *** byte-compile and prepare package for lazy loading*
    *Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : *
  • namespace 'rlang' 0.4.7 is already loaded, but >= 1.0.2 is required*
    Calls: ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace
    Execution halted
    ERROR: lazy loading failed for package 'pillar'
    ** removing 'D:/Documents/R/win-library/3.6/pillar'*
    ** restoring previous 'D:/Documents/R/win-library/3.6/pillar'*
    Warning in install.packages :
  • installation of package ‘pillar’ had non-zero exit status*
    ** installing source package 'stringr' ...*
    *** package 'stringr' successfully unpacked and MD5 sums checked*
    *** using staged installation*
    *** R*
    *** data*
    **** moving datasets to lazyload DB*
    *** inst*
    *** byte-compile and prepare package for lazy loading*
    *Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : *
  • namespace 'rlang' 0.4.7 is being loaded, but >= 1.0.0 is required*
    Calls: ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace
    Execution halted
    ERROR: lazy loading failed for package 'stringr'
    ** removing 'D:/Documents/R/win-library/3.6/stringr'*
    ** restoring previous 'D:/Documents/R/win-library/3.6/stringr'*
    Warning in install.packages :
  • installation of package ‘stringr’ had non-zero exit status*
    ERROR: dependency 'tidyr' is not available for package 'broom'
    ** removing 'D:/Documents/R/win-library/3.6/broom'*
    Warning in install.packages :
  • installation of package ‘broom’ had non-zero exit status*

The downloaded source packages are in

  • ‘C:\Users\Kibru\AppData\Local\Temp\RtmpSEpgeM\downloaded_packag*

Hi @Kibr
Welcome to the Community Forum.

These errors are occurring because your Windows machine does not have the required tools installed to compile R packages from their source code.

However, with Windows, compilation is not necessary as you can simply download the pre-compiled binary. This should be the default. If you are asked whether you want to "compile from source" answer "no".

P.s. You are using a very old version of R (3.6), the latest version is 4.4.1

You are using version 3.6 of R while the current version is 4.4.

To install packages in 3.6 you will need to install the compiler software in the RTools software (it is NOT a package). I believe that you will need version 3.5 of the RTools software. The blue link in the third paragraph of your post will take you to the RTools site on CRAN. You will need to click on the link to old versions of RTools. I am not a Windows user, so will not be of much help if you have troubles.

A better solution is to update the version of R on your computer.