R Setup - gizotso/R GitHub Wiki
print(version) : R version (release, os, ...). R.version
print(sessionInfo()) : R session info, confirm attached packages
options()
memory.size(), memory.limit(), memory.limit(size=2000) # 2000MB
object.size(), memory.profile()
Sys.setlocale(): linguistic and encoding options
Sys.setenv(LANGUAGE='en')
R:.
ββββbin
β ββββi386
β ββββx64
β ββββR.exe
β ββββRscript.exe
ββββdoc
ββββetc
ββββinclude
ββββlibrary
ββββmodules
ββββshare
ββββsrc
ββββTcl
ββββtests
ββββ...
- R_HOME : R directory
- R_HOME_bin : where you find R executables (R.exe, Egui.exe,...). To be added to the PATH variable.
- R_LIBS (optional): custom directory for R packages
- R_LIBS_USER : automatically set to folder under user's home (ex: "C:/Users/family/Documents/R/win-library/3.2")
- HOME : automatically set to user's home directory (ex: "C:/Users/family/Documents")
:: ------ SetEnv.bat -----
:: R setup (since R3.2 need to tweak to point correct version i386/x64)
set R_HOME=C:\Tools\R\R-3.2.5
IF "%PROCESSOR_ARCHITECTURE%"=="x86" (set R_HOME_bin=%R_HOME%\bin\i386) else (set R_HOME_bin=%R_HOME%\bin\x64)
set PATH=%R_HOME_bin%;%PATH%:: Set en variables permanently for current user
:: (need to restart Cmd to be effective: echo %R_HOME%)
setx R_HOME "C:\Tools\R\R-3.2.5"
setx R_HOME_bin %R_HOME%\bin\x64
setx R_LIBS "C:\Tools\R\RLibs-3.2.5"Setting environment variables (ignored if R invoked with --no-environ)
- Renviron.site : At startup, Lookup : 1.$R_ENVIRON, 2. if unset/empty, $R_HOME/etc/Renviron.site. Note : this config file does not exists on a factory-fresh install
- .Renviron :1. current dir, 2. user's home directory
.Renviron
## Linux
R_LIBS=~/R/library
## Windows
R_LIBS=C:/R/librarySys.getenv('R_LIBS_USER')
Sys.getenv("R_HOME")
# [1] "T:/PortableApps/PortableApps/R-Portable/App/R-Portable"
normalizePath(Sys.getenv("R_HOME"))
# [1] "T:\\PortableApps\\PortableApps\\R-Portable\\App\\R-Portable"
R.home()
# [1] "C:/Tools/R/R-3.2.5"
R.home("doc")
# Library Search Path
.libPaths()
# add to Lib Path
.libPaths('T:\\SWDev\\lib'))
# Home dir
Sys.getenv("HOME")
path.expand("~")Set env
Sys.setenv()
Sys.setlocale() # linguistic and encoding options
Sys.setenv(LANGUAGE='en')# set error message language
https://stat.ethz.ch/R-manual/R-devel/library/base/html/Startup.html
- Rprofile.site (ignored if R invoked with --no-site-file) Lookup : $R_PROFILE, if unset try $R_HOME/etc/Rprofile.site. This code is loaded into package base
- .Rprofile (ignored if R invoked with --no-init-file) Lookup : 1. current dir, 2. user's home directory and sources it into the user workspace. ? $R_PROFILE_USER if set
- .First (.Rprofile or Rprofile.site or .Rdata) : if found on the search path, it is executed as .First()
R> example(startup) will provide Renviron and Rprofile examples
R> help(startup) will provide help
R> options () will show all options
Rprofile.site
# set a site library
# .Library.site <- file.path(chartr("\\", "/", R.home()), "site-library")
# if R_LIBS env variable is not set
# Sys.setenv(R_LIBS = "T:/PortableApps/R/R_lib_32")
# add R_LIBS to library Path
.libPaths(Sys.getenv('R_LIBS'))
# alias qq to exit without asking for saving
qq <- function() { q("no") }Rprofile.site sample
# Sample Rprofile.site file
# ${R_HOME}/etc/Rprofile.site
# source : http://www.statmethods.net/interface/customizing.html
# Things you might want to change
# options(papersize="a4")
# options(editor="notepad")
# options(pager="internal")
# R interactive prompt
# options(prompt="> ")
# options(continue="+ ")
# to prefer Compiled HTML
help options(chmhelp=TRUE)
# to prefer HTML help
# options(htmlhelp=TRUE)
# General options
options(tab.width = 2)
options(width = 130)
options(graphics.record=TRUE)
.First <- function(){
library(Hmisc)
library(R2HTML)
cat("\nWelcome at", date(), "\n")
}
.Last <- function(){
cat("\nGoodbye at ", date(), "\n")
}print(version)
print(.libPaths())
[1] "C:/Tools/R/RLibs-3.2.5" "C:/Tools/R/R-3.2.5/library"- https://www.r-bloggers.com/fun-with-rprofile-and-customizing-r-startup/
- https://csgillespie.github.io/efficientR/3-3-r-startup.html
- http://www.statmethods.net/interface/customizing.html
- http://blog.revolutionanalytics.com/2013/10/sample-rprofile.html
- https://cran.r-project.org/doc/contrib/Lemon-kickstart/kr_first.html
- https://stackoverflow.com/questions/15170399/changing-r-default-library-path-using-libpaths-in-rprofile-site-fails-to-work
Associate .R, .Rmd files to be opened with RStudio
Some utilities are packaged within RStudio : GnuGrep <$RStudio>\bin\gnugrep
R:.
ββββbin
β ββββgnugrep
β ββββgnudiff
β ββββpandoc
β rstudio.exe
ββββR
β ββββmodules
β Options.R, ServerOptions.R, ...
ββββresources
ββββwwww
ββββwww-symbolmaps
- R commander (Rcmdr package)
- Rattle/TogaWare : Rattle: A Graphical User Interface for Data Mining using R
- http://rattle.togaware.com/
- http://rattle.togaware.com/rattle-install-mswindows.html
- Book : Data mining with Rattle and R
- R Poor Man GUI (pmg package): https://en.wikibooks.org/wiki/R_Programming/Settings#Poor_Man.27s_GUI_.28pmg.29
- Rexcel
- Plugin eclipse: StatET (walware)
install.packages(c("rj", "rj.gd"), repos="http://download.walware.de/rj-1.1")- For RJ 2.0 (StatET 3.4):
install.packages(c("rj", "rj.gd"), repos="http://download.walware.de/rj-2.0")
- R Web Interfaces
- Rook : a web server interface for R
- Rapache : Web Application Development with R and Apache
- https://www.opencpu.org/
- Rserve, R-node
- Shiny by Rstudio : a web application framework (based on node.js) shinydata
- ShinyApps