简体   繁体   中英

r - my rprofile is running multiple times

My .Rprofile always runs twice. I looked at this thread and think it might be because the slashes are going in various directions.

I only have code in the paths pointing at C:/Users/rileyj3/.Rprofile (results 1, 2 & 4). Does anyone know how to resolve?

expr path exists
file.path(getwd(), ".Rprofile") C:/Users/rileyj3/.Rprofile TRUE
file.path(Sys.getenv("HOME"), ".Rprofile") C:\Users\rileyj3/.Rprofile TRUE
file.path(Sys.getenv("R_HOME"), "etc", "Rprofile.site") C:/PROGRA~1/R/R-42~1.2/etc/Rprofile.site TRUE
Sys.getenv("R_PROFILE") C:\Users\rileyj3.Rprofile TRUE
Sys.getenv("R_PROFILE_USER") FALSE

 library(tidyverse) tibble( expr = c( 'file.path(getwd(), ".Rprofile")', 'file.path(Sys.getenv("HOME"), ".Rprofile")', 'file.path(Sys.getenv("R_HOME"), "etc", "Rprofile.site")', 'Sys.getenv("R_PROFILE")', 'Sys.getenv("R_PROFILE_USER")' ) ) |> mutate( path = map_chr(expr, ~parse(text =.x) |> eval()), exists = file.exists(path) ) |> knitr::kable()

You can see the details of R read Rprofile files on the ?Startup help page.

R will look for both a site-wide and user-specific profile. Since you have a value set for R_PROFILE, that's considered a site-wide profile so it's run. Then when R looks for a user-specific value, it finds the one in your home directory so it runs that one as well. R doesn't check to see if the site-wide and specific files are the same. You should probably remove the R_PROFILE system environment variable since you seem to be setting a user-specific values there or move it to R_PROFILE_USER.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM