When you install packages for your R, the path must not contain any non-English characters.

If the default path contains non-English characters, you can try the followings.

Windows Users

Suppose that you want to install package “stargazer”, you should first create a folder for the package, e,g, C:/test.

Then, when downloading the package, specify that it will be downloaded to the specific folder:

install.packages("stargazer", repos = "http://cran.us.r-project.org", lib = "C:/test")   
## package 'stargazer' successfully unpacked and MD5 sums checked
## 
## The downloaded binary packages are in
##  C:\Users\Li Xi\AppData\Local\Temp\RtmpScbgEt\downloaded_packages

And when using the package, you need to load from that folder:

library("stargazer", lib.loc="C:/test")   
## Warning: package 'stargazer' was built under R version 4.1.1
## 
## Please cite as:
##  Hlavac, Marek (2018). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2.2. https://CRAN.R-project.org/package=stargazer

Mac Users

Suppose that you want to install package “stargazer”, you should first create a folder for the package, e,g, /Users/xili/Desktop/package.

Then, when downloading the package, specify that it will be downloaded to the specific folder:

install.packages("stargazer", repos = "http://cran.us.r-project.org", lib = "/Users/xili/Desktop/package")   
## Warning: package 'stargazer' is in use and will not be installed

And when using the package, you need to load from that folder:

library("stargazer", lib.loc="/Users/xili/Desktop/package")