It looks like the library folders are locked, and can't be overwritten.
The key pieces of information, to me, are
Installing package into �C:/Users/---/OneDrive/Documents/R/win-library/3.5�
and
cannot remove prior installation of package ‘lmtest’
In my experience, when this happens, I usually go to C:/Users/---/OneDrive/Documents/R/win-library/3.5
, delete the lmtest
folder. With the folder deleted, install.packages
should be able to write the package.
There's probably a more elegant way to do this, but that's the solution I've been using.