.Rprofile

Published by onesixx on

https://rviews.rstudio.com/2017/04/19/r-for-enterprise-understanding-r-s-startup/
https://support.rstudio.com/hc/en-us/articles/360047157094-Managing-R-with-Rprofile-Renviron-Rprofile-site-Renviron-site-rsession-conf-and-repos-conf

~/.Rprofile

R 환경을 사용자에 맞게 바꾸기 위해, 항상 처음 읽어들이는 HOME (또는 working directory)에서
.Rprofile파일을 찾는다.
홈디렉토리에 ~/.Renviron과 ~/.Rprofile 파일이 있으면 수정하고 없으면 생성한다. (처음엔 없다)

위치

여기서는 예로, ~/.Rprofile 에 R을 시작할때, 매번 사용하게 되는 명령어를 넣어 둔다.

usethis::edit_r_profile()
.First <- function(){
\tlibrary(tidyverse)
  library(data.table)
  cat("\
 Welcome Sixx at ------------>>>>>>>>>>>>", date(), "\
")
}

.Last <- function(){
  cat("\
 Goodbye Sixx at ------------>>>>>>>>>>>>", date(), "\
")
}
Sys.setenv(LANG = "en_US.UTF-8")
options(tab.width = 4)
options(help_type="html")
options(browser="C:/Program Files (x86)/Google/Chrome/Application/chrome.exe")

.First <- function(){
 library(tidyverse)
 library(data.table)
 cat("\
Welcome at", date(), "\
")
 setwd("C:/RScience")
}

.Last <- function(){
 cat("\
Goodbye at ", date(), "\
")
}

~/.Renviron

usethis::edit_r_environ()

Rprofile.site

R: Initialization at Start of an R Session

위치는 R.home()/etc폴더 아래,

> R.home()
Mac [1] "/Library/Frameworks/R.framework/Resources"
Win [1] "C:/PROGRA~1/R/R-36~1.1"
Linx[1] "/usr/lib/R"
/usr/lib/R/etc$ ls -al $R_HOME/etc
total 28
...
lrwxrwxrwx. 1 root root   20 Dec 13  2019 Rprofile.site -> /etc/R/Rprofile.site

lrwxrwxrwx. 1 root root   15 Dec 13  2019 Renviron -> /etc/R/Renviron
lrwxrwxrwx. 1 root root   20 Dec 13  2019 Renviron.site -> /etc/R/Renviron.site
-rw-r--r--. 1 root root 1692 Dec 13  2019 Renviron.orig
-rw-r--r--. 1 root root 1995 Dec 13  2019 Renviron.ucf

lrwxrwxrwx. 1 root root   19 Dec 13  2019 repositories -> /etc/R/repositories

모든 사용자의 설정을 변경하려면 /usr/lib/R/etc (/etc/R/) 아래 Renviron, Renviron.site, Rprofile.site을 사용한다.

<참고>

getOption("scipen")  # 0 
getOption("digits")  # 7

options(scipen=0, digits=7)

> 1234567890123
[1] 1.234568e+12
> format(1234567890123, scientific=F)
[1] "1234567890123"

> 1e6
[1] 1e+06
> format(1e6, scientific=F)
[1] "1000000"

# 4
> options(scipen=9)
> 1e13
[1] 10000000000000
> 1e14
[1] 1e+14

scipen : 아주 큰 수나 작은수에 대해서 scientific notation(e+10) 사용하지 않도록

Categories: R Basic

onesixx

Blog Owner

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x