html of rmarkdown file (.Rmd) is not displayed correctly in browser

送分小仙女□ 提交于 2019-12-02 10:22:35

A friend of mine got the solution for this problem: The .libPaths() in our company was defined as

.libPaths()
#> [1] "\\\\userhome/my_user_name/R/win-library/3.4"   # note the four \\\\
#> [2] "C:/Program Files/R/3.4.2/library"

After changing the first location to

.libPaths()
#> [1] "C:/Users/my_user_name/R/win-library/3.4.2"     # path starts with C:/
#> [2] "C:/Program Files/R/3.4.2/library"

the .Rmd renders as expected :).

We placed the following function in our .Rprofile. It creates the directory step-by-step and adds it to .libPaths().

# install packages locally within user profile
(function() {
  components <- list('C:/', 'users', Sys.info()['login'], 'R',
                     'win-library', paste0(R.Version()$major,
                                           '.',
                                           R.Version()$minor))

  # loop over components and create dir step-by-step
  # (recursive = TRUE leads to errors)
  for (k in 4:length(components)) {
    p <- do.call(file.path, components[1:k])
    dir.create(p, showWarnings = FALSE, recursive = FALSE)
  }

  path <- do.call(file.path, components)
  .libPaths(c(path, .Library))
})()

Created on 2018-09-24 by the reprex package (v0.2.1)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!