September 26, 2013
Install R on Ubuntu
May 18, 2012
Install R packages
> install.packages("/home/data/Downloads/foreach_1.4.0.tar.gz", repos=NULL, type="source")
what a PITA.
- this one shows where things will be installed
> install.packages("foreach", dependencies=TRUE)
- this one installed into a temp directory = FAIL
March 07, 2011
Emacs related commands
For the timing being, I am going to be using Emacs as an editor for my R scripts. Welcome to the land of confusing command line shortcuts:
R specific guide.
SHOW BUFFERS - ctrl-x ctrl-b
KILL BUFFER - ctrl-x k
SEND ALL CODE TO R - ctrl-x ctrl-b
- note similarity to SHOW BUFFERS...
RECALL R COMMAND - alt-p
Load R packages
Open the R command line.
$ sudo R
To load (have the functions available) use:
Install R Statistical Package
Documentation of a process.
Step-by-step instructions from a kindred soul.
Official instructions from the R Project.
More official instructions.
1. Open a terminal
2. Add a gpg (pgp?) key to authenticate downloads from R.
- What is a gpg key?
$ gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
$ gpg -a --export E084DAB9 | sudo apt-key add -
- The GPG key may change occasionally. The most up to date key can be found in the SECURE APT section of this page.
3. Add a mirror site from which to download R-related code to sources.list
$ sudo gedit /etc/apt/source.list
Add this line to the bottom:
deb http://lib.stat.cmu.edu/R/CRAN/bin/linux/ubuntu lucid/
4. Install the R code
$ sudo apt-get install r-base
Note: This tutorial mentions additional commands and build-essential at steps 7 & 8 but the above command appears to install that code.
5. Start and Update R
$ sudo R
Potentially helpful comment:
I also like 'sudo apt-get install littler' and I then copy or link
install.r to /usr/local/bin and just use
$ sudo install.r foo far fie foo
which would then install the (hyopthetical) packages foo, far, fie and foo
6. Install and Open the R Commander GUI
7. File Location Notes
/usr/share/R for architecture-independent files.
Downloaded Packages go here:
-- 'base R' and recommended packages are in /usr/lib/R/library/
-- Debian-packaged R packages are in /usr/lib/R/site-library/
-- packages installed by you / R are in /usr/local/lib/R/site-library/
November 16, 2009
Work with Excel sheets in R
Documentation of the mundane follows...
I am going to reformat one of our larger datasets, the Welch-Eggleton limnological dataset for South Fishtail Bay that spans from 1913-1950 with temperature, dissolved oxygen and more variables measured.
Good things to know thus far:
Using the R stats package, the xlsReadWrite package can import the worksheets from an Excel file. Use the read.xls command.
The dataTimeToStr routine documented here is useful for getting the Excel date/time number (4970??) into an actual date. Another reason not to use Excel, you need a special function to read dates.
Also, I am using Notepad++ to write scripts and downloaded this .exe file to tell Notepad++ about the R syntax.