Skip to content

Systems

morota edited this page Dec 19, 2012 · 1 revision

Get commandline arguments when the R session was invoked

# Mac OS X
commandArgs()
[1] "R"                 "--no-save"         "--no-restore-data" "--gui=cocoa"
# Ubuntu
commandArgs()
[1] "/usr/lib64/R/bin/exec/R"

Check if you are running 32-bit or 64-bit

# 32-bit
.Machine$sizeof.pointer
[1] 4
>
# 64-bit
.Machine$sizeof.pointer
[1] 8

System commands

system2("whoami")
gota

system2("echo" , "$PATH")
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
Sys.which('make')
           make 
"/usr/bin/make"

a <- system("whoami", intern=TRUE)
a
[1] "gota"

?Sys.chmod
?Sys.file

Environment variables

Sys.getenv('R_HOME')
[1] "/usr/lib64/R"
Sys.getenv('R_LIBS')
[1] "~/lib64/R/Rlib:"
Sys.getenv("LANGUAGE")
[1] "en_US:en"
?'environment variables'

Read manuals

RShowDoc("R-exts")
RShowDoc("R-intro")
RShowDoc("KEYWORDS ")
?RShowDoc

Check capabilities

capabilities()
    jpeg      png     tiff    tcltk      X11     aqua http/ftp  sockets 
    TRUE     TRUE    FALSE     TRUE     TRUE    FALSE     TRUE     TRUE 
  libxml     fifo   cledit    iconv      NLS  profmem    cairo 
    TRUE     TRUE     TRUE     TRUE     TRUE     TRUE     TRUE 

Display path to a file

file.path(R.home(), "bin", "R")

Get a home directory

normalizePath("~")
[1] "/home/gota"

Platform information

.Platform

Clone this wiki locally