install.package() help document says that:
There are various options for locking: these differ between source and binary installs.
By default for a source install, the library directory is ‘locked’ by creating a directory
00LOCK within it. This has two purposes: it prevents any other process installing into that library concurrently, and is used to store any previous version of the package to restore on error. A finer-grained locking is provided by the option --pkglock which creates a separate lock for each package: this allows enough freedom for parallel installation. Per-package locking is the default when installing a single package, and for multiple packages when
Ncpus > 1L . Finally locking (and restoration on error) can be suppressed by --no-lock.
For a macOS binary install, no locking is done by default. Setting argument
TRUE (it defaults to the value of
getOption("install.lock", FALSE) ) will use per-directory locking as described for source installs. For Windows binary install, per-directory locking is used by default (
lock defaults to the value of
getOption("install.lock", TRUE) ). If the value is
"pkglock" per-package locking will be used.
If package locking is used on Windows with
libs_only = TRUE and the installation fails, the package will be restored to its previous state.
Note that it is possible for the package installation to fail so badly that the lock directory is not removed: this inhibits any further installs to the library directory (or for
--pkglock , of the package) until the lock directory is removed manually.
According to that, you may first looking for any folder in ‘C:\Users\USER\AppData\Local\R\win-library\4.2’ which name stars with "00LOCK" and delete it. Then try install the package again.
Another solution is using parameter
INSTALL_opts = '--no-lock' while installing the package, like
install.packages("onewaytests", INSTALL_opts = '--no-lock')