Problem with Error in nchar(homeDir) : invalid multibyte string, element 1

R has problems with multibyte characters in your package library path, I recommend you to set your package library in a folder with ASCII characters only.

You can change the default library folder by setting your R_LIBS_SITE environmental variable in a .Reviron or .Rprofile file. For example:

# In a .Renviron file you can set it by adding a line like this one with the desired location 
R_LIBS_SITE="C:\\Program Files\\R\\R-4.2.1\\library"

For a more detailed explanation, you can read this blog post

In theory the latest R version should be able to handle non-ASCII characters but you would need to activate the experimental utf8 encoding support on Windows, which cames with unexpected issues with other software.