knitr::opts_chunk$set(echo = TRUE, comment=" ##", error=TRUE, collapse=TRUE) library(data.table) library(magrittr)
Normally, I use neovim + plugin nvim-R as my IDE. Recently I tried to install RStudio but ran into errors.
Seems each time I update R, I run into trouble with one or more directories that R uses. The reasons probably relate to the past of switching from RStudio to neovim or compiling from source one time and using binaries the next.
Over time, my R setup has collected diretories with various permuations of "lib", "library", "local." Rather than sort it all out, I decided to remove R and begin again.
I found this the Ubuntu/Debian instructions helpful: https://ftp.osuosl.org/pub/cran/bin/linux/debian, which explains some of R environmental variables.
So here I collect useful R environment variables I found to be important. To ease navigation, I also set shell environment variables (I use zsh ) to match R.
Of course, your experience will differ, but getting a good grasp on the R environment variables may avoid some future pain.
R_env <- c("R_HOME", "R_LIBS_USER", "R_LIBS_SITE", NA, NA) paths <- c("/usr/lib/R/", "/home/jim/R/x86_64-pc-linux-gnu-library/4.1/", "/usr/lib/R/library/", "/etc/R/Renviron", "~/.Renviron") zsh_env <- c("R_HOME", "R_LIBS_USER", "R_LIBS_SITE", NA, NA) dt <- data.table(R_env = R_env, path = paths, zsh_env = zsh_env)
dt %>% knitr::kable()
Here is one way to confirm which directories R is using for packages.
.libPaths()
s <- Sys.getenv() names <- names(s) head(names) head(s[grep(pattern = "^R", x = names)]) s[grep(pattern = "^R_LIBS", x = names)]
s[grep(pattern = "^R_LIBS", x = names)]
if (F) help(.libPaths)
knitr::knit_exit()
3 directories most important, ~/R/armv71.....-library/4.0/ (pkgs I add) /usr/local/lib/R/ where R prefers R_HOME be (leave it alone!)
run try_things_here/0088_base package commands. (shows which dir/which pkgs)
{ file <- "/home/jim/code/jimTools/rmd/0999_R_upgrade_notes.rmd" file <- "rmd/0999_R_upgrade_notes.rmd" file <- basename(file) file file <- paste0("rmd/",file) file } file <- "rmd/0999_R_upgrade_notes.rmd" rmarkdown::render(file, output_format="html_document", #output_format="pdf_document", output_dir="~/Downloads/print_and_delete")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.