but the error messages provided by R are usually fairly explicit about what went wrong.
can you provide them? what showed on the console when you install.packages("xfun") ?
This is the error message I received, I think I went down a rabbit hole with "xfun" because initially I wasn't trying to load it an yet it was the error message:
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
namespace ‘xfun’ 0.12 is being loaded, but >= 0.15 is required
The error message is telling you that you have an old version of xfun installed and that you need to update it, the solution to this would be to update xfun with this command.
install.packages("xfun")
Apparently the installation process of xfun has not been successful, that is why you are being asked to post the whole message you get when you run that specific command.