.libPaths() raising error because Documents folder could not be found by R

my solution is to modify windows environment variables
control panel/system/advanced system settings

  1. add an environment variable for R_USER
    1.1 variable name: R_USER
    1.2 click "Browse Directory" and select the path where the application is installed, then click "OK".
    for example: C:\Program Files\R\R-4.2.1

  2. modify the Path
    click "Browse Directory" and select the path where the application is installed, then click "OK".
    for example: C:\Program Files\R\R-4.2.1