You are here:
Vanderbilt Biostatistics Wiki
>
Main Web
>
StatComp
>
RS
>
RConfiguration
(27 Apr 2015,
JoAnnAlvarez
)
(raw view)
E
dit
A
ttach
---+ Configuring R ---++ Using =html= Help Facility Linux users of R version 2.10 and later may want to take advantage of the new dynamic =html= rendering of help pages. The =konqueror= browser under =KDE= is efficient to use for this purpose, and can be told to open new help windows as new tabs on the existing =konqueror= invocation. That way you can switch back and forth between help pages for different functions. To set this up with the =chromium-browser= for example, put the following lines in your =~/.Rprofile= file: <highlight> options(help_type='html', browser='chromium-browser') </highlight> =RStudio= is probably a better choice however. ---++ Other R Profile Options To use the =chromium-browser (sudo apt-get install chromium-browser)= and to specify a nearby =CRAN= repository and take control of where downloaded packages are installed, put the following in =~/.Rprofile= <highlight> options(help_type='html', browser='chromium-browser', repos='http://cran.rstudio.com', lib='/usr/local/lib/R/site-library') </highlight> Note that the =lib= option does not always take, and certain things you run in R can redefine the library path. To be certain of where packages are installed, do something like <highlight> install.packages(...., repos='http://cran.rstudio.com', lib='/usr/local/lib/R/site-library') </highlight> You may want to put the following code in =~/.Rprofile= so that you can install one or more packages using e.g. =installPac(c('rms','quantreg'))= and likewise so it's easy to update all packages using =updatePac()= <highlight> installPac <- function(p) install.packages(p, repos='http://cran.rstudio.com', lib='/usr/local/lib/R/site-library') updatePac <- function(checkBuilt=FALSE, ...) update.packages(repos='http://cran.rstudio.com', instlib='/usr/local/lib/R/site-library', checkBuilt=checkBuilt, ...) </highlight> ---++ Using [[http://rstudio.org][RStudio]] If you run R through !RStudio put the following line in =~/.bashrc= so you can invoke it from the command =rstudio= <verb> alias rstudio="/usr/lib/rstudio/bin/rdesktop" </verb> ---++ Setup for =knitr= See KnitrHowto for commands to put in =~/.Rprofile= to make it easy to get publication-quality =knitr= output (or use the =knitrSet= function in the =Hmisc= package) Here's an example [[%ATTACHURL%/Rprofile][.Rprofile]] - save it to your home directory (in Windows 7 this is your =Documents= directory if at the Windows command prompt, i.e., =c:\Users\yourname\Documents=, otherwise in Explorer this is your home directory =My Documents=) as ".Rprofile" (the dot "." is required). Or run the following: <highlight> setwd('~/') download.file('http://biostat.mc.vanderbilt.edu/wiki/pub/Main/RConfiguration/Rprofile', '.Rprofile') </highlight> ---++ Sourcing code from a website. You can source code from a website using source("url"). However, if the url has the secure thing, https, it won't work. One way to overcome this is to install a package called RCurl which implements curl. Then you can do this: ---+++ Setup for Windows users for wget *Note*: The version of of =getRs= in =.Rprofile= posted 2015-04-21 does not need =wget=. <verbatim> sourceHttps <- function(url){ library(RCurl) eval(expr = parse(text = getURL(url)))} </verbatim> It is also convenient to use method='wget' (in download.file, url.show, etc.). To do this you must have wget installed. Go [[http://users.ugent.be/~bpuype/wget here]]. Right click on =wget.exe= and save it in your normal Downloads area. Open Windows Explorer, go to Downloads, right click and hit Copy. Go to Computer ... OS (C:) ... Windows ... System32, right click, hit Paste. Approve the use of administrator privileges, then save wget.exe in System32. This will put wget.exe in the system path for use with R. ---+++ Setup wget for Macintosh OSX users Mac OS X 10.10 Yosemite does not come with the command line utility wget installed. The web site http://coolestguidesontheplanet.com/install-and-configure-wget-on-os-x/ contains instructions for installing wget. These instructions are for Yosemite, but should work for other recent versions of OS X. A more manual process is documented at http://coolestguidesontheplanet.com/install-and-configure-wget-on-os-x/.
Attachments
2
Attachments
2
Topic attachments
I
Attachment
Action
Size
Date
Who
Comment
EXT
Rprofile
manage
8.9 K
21 Apr 2015 - 15:02
FrankHarrell
example Rprofile
r
graphicsSet.r
manage
7.0 K
07 Apr 2015 - 16:17
FrankHarrell
Graphics defaults setup
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r32
<
r31
<
r30
<
r29
|
B
acklinks
|
V
iew topic
|
Edit
w
iki text
|
M
ore topic actions
Topic revision: r32 - 27 Apr 2015,
JoAnnAlvarez
Main
Department Home Page
Biostatistics Graduate Program
Vanderbilt University Medical Center
Main Web
Main Web Home
Search
Recent Changes
Changes
Topic list
Biostatistics Webs
Archive
Main
Sandbox
System
Register
|
Log In
Copyright © 2013-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Vanderbilt Biostatistics Wiki?
Send feedback