Cannot install packages "SurvMetrics"

> library(SurvMetrics)
Error in library(SurvMetrics) : there is no package called ‘SurvMetrics’
In addition: Warning message:
R graphics engine version 16 is not supported by this version of RStudio. The Plots tab will be disabled until a newer version of RStudio is installed. 
> library(survival)
> time = c(1,1,2,2,2,2,2,2)
> status = c(0,1,1,0,1,1,0,1)
> predicted = c(2,3,3,3,4,2,4,3)
> Cindex(Surv(time,status),predicted)
Error in Cindex(Surv(time, status), predicted) : 
  could not find function "Cindex"
> library(SurvMetrics)
Error in library(SurvMetrics) : there is no package called ‘SurvMetrics’
> install.packages("SurvMetrics")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/user/AppData/Local/R/win-library/4.4’
(as ‘lib’ is unspecified)
also installing the dependencies ‘fs’, ‘rappdirs’, ‘cachem’, ‘memoise’, ‘mime’, ‘sass’, ‘bslib’, ‘fontawesome’, ‘jquerylib’, ‘tinytex’, ‘viridis’, ‘rmarkdown’, ‘TH.data’, ‘sandwich’, ‘checkmate’, ‘htmlwidgets’, ‘rstudioapi’, ‘iterators’, ‘Hmisc’, ‘polspline’, ‘multcomp’, ‘htmlTable’, ‘cmprsk’, ‘doParallel’, ‘mets’, ‘plotrix’, ‘Publish’, ‘ranger’, ‘RcppArmadillo’, ‘foreach’, ‘rms’, ‘riskRegression’, ‘timereg’, ‘pec’

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/fs_1.6.5.zip'
Content type 'application/zip' length 414897 bytes (405 KB)
downloaded 405 KB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/rappdirs_0.3.3.zip'
Content type 'application/zip' length 52861 bytes (51 KB)
downloaded 51 KB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/cachem_1.1.0.zip'
Content type 'application/zip' length 74032 bytes (72 KB)
downloaded 72 KB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/memoise_2.0.1.zip'
Content type 'application/zip' length 51452 bytes (50 KB)
downloaded 50 KB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/mime_0.12.zip'
Content type 'application/zip' length 40893 bytes (39 KB)
downloaded 39 KB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/sass_0.4.9.zip'
Content type 'application/zip' length 2614588 bytes (2.5 MB)
downloaded 2.5 MB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/bslib_0.9.0.zip'
Content type 'application/zip' length 5924128 bytes (5.6 MB)
downloaded 5.6 MB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/fontawesome_0.5.3.zip'
Content type 'application/zip' length 1391180 bytes (1.3 MB)
downloaded 1.3 MB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/jquerylib_0.1.4.zip'
Content type 'application/zip' length 526142 bytes (513 KB)
downloaded 513 KB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/tinytex_0.55.zip'
Content type 'application/zip' length 146444 bytes (143 KB)
downloaded 143 KB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/viridis_0.6.5.zip'
Content type 'application/zip' length 3014771 bytes (2.9 MB)
downloaded 2.9 MB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/rmarkdown_2.29.zip'
Content type 'application/zip' length 2698975 bytes (2.6 MB)
downloaded 2.6 MB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/TH.data_1.1-3.zip'
Content type 'application/zip' length 8756621 bytes (8.4 MB)
downloaded 8.4 MB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/sandwich_3.1-1.zip'
Content type 'application/zip' length 1506037 bytes (1.4 MB)
downloaded 1.4 MB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/checkmate_2.3.2.zip'
Content type 'application/zip' length 752323 bytes (734 KB)
downloaded 734 KB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/htmlwidgets_1.6.4.zip'
Content type 'application/zip' length 814171 bytes (795 KB)
downloaded 795 KB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/rstudioapi_0.17.1.zip'
Content type 'application/zip' length 346676 bytes (338 KB)
downloaded 338 KB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/iterators_1.0.14.zip'
Content type 'application/zip' length 353906 bytes (345 KB)
downloaded 345 KB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/Hmisc_5.2-2.zip'
Content type 'application/zip' length 3810694 bytes (3.6 MB)
downloaded 3.6 MB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/polspline_1.1.25.zip'
Content type 'application/zip' length 604962 bytes (590 KB)
downloaded 590 KB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/multcomp_1.4-28.zip'
Content type 'application/zip' length 737733 bytes (720 KB)
downloaded 720 KB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/htmlTable_2.4.3.zip'
Content type 'application/zip' length 433010 bytes (422 KB)
downloaded 422 KB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/cmprsk_2.2-12.zip'
Content type 'application/zip' length 93437 bytes (91 KB)
downloaded 91 KB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/doParallel_1.0.17.zip'
Content type 'application/zip' length 192359 bytes (187 KB)
downloaded 187 KB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/mets_1.3.5.zip'
Content type 'application/zip' length 6085201 bytes (5.8 MB)
downloaded 5.8 MB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/plotrix_3.8-4.zip'
Content type 'application/zip' length 1158289 bytes (1.1 MB)
downloaded 1.1 MB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/Publish_2023.01.17.zip'
Content type 'application/zip' length 466670 bytes (455 KB)
downloaded 455 KB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/ranger_0.17.0.zip'
Content type 'application/zip' length 799237 bytes (780 KB)
downloaded 780 KB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/RcppArmadillo_14.2.3-1.zip'
Content type 'application/zip' length 2058749 bytes (2.0 MB)
downloaded 2.0 MB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/foreach_1.5.2.zip'
Content type 'application/zip' length 149890 bytes (146 KB)
downloaded 146 KB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/rms_7.0-0.zip'
Content type 'application/zip' length 2532777 bytes (2.4 MB)
downloaded 2.4 MB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/riskRegression_2023.12.21.zip'
Content type 'application/zip' length 1993205 bytes (1.9 MB)
downloaded 1.9 MB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/timereg_2.0.6.zip'
Content type 'application/zip' length 999745 bytes (976 KB)
downloaded 976 KB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/pec_2023.04.12.zip'
Content type 'application/zip' length 523649 bytes (511 KB)
downloaded 511 KB

Warning in install.packages :
  the 'wininet' method is deprecated for http:// and https:// URLs
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/SurvMetrics_0.5.1.zip'
Content type 'application/zip' length 106813 bytes (104 KB)
downloaded 104 KB

package ‘fs’ successfully unpacked and MD5 sums checked
Error in install.packages : ERROR: failed to lock directory ‘C:\Users\user\AppData\Local\R\win-library\4.4’ for modifying
Try removing ‘C:\Users\user\AppData\Local\R\win-library\4.4/00LOCK’

Do you have other R sessions running? Make sure that you don't and try deleting that lockfile.

Alternatively, try pak [1], then you don't need to worry about lock files.

[1] All about installing pak. — Installing pak • pak