September 26, 2013

Install R on Ubuntu

You would think the official readme would be sufficient but I received a public key error following their instructions. This how to had two extra steps that added the key (somehow.)

Posted by kkwaiser at 09:41 AM | Comments (0)

May 18, 2012

Install R packages

> install.packages("/home/data/Downloads/foreach_1.4.0.tar.gz", repos=NULL, type="source")

what a PITA.

> .libPaths()
- this one shows where things will be installed

> install.packages("foreach", dependencies=TRUE)
- this one installed into a temp directory = FAIL

Posted by kkwaiser at 03:43 PM | Comments (0)

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:

Overall guide.

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...


Posted by kkwaiser at 12:39 PM | Comments (0)

Load R packages

Open the R command line.

$ sudo R
> install.packages('packageName')

To load (have the functions available) use:

> library('packageName')

Posted by kkwaiser at 12:26 PM | Comments (0)

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 --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 lucid/

Note: A list of mirrors is available.
Note: See the INSTALLATION first section of this page for more on setting up a mirror.

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
> update.packages()

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
from CRAN.

6. Install and Open the R Commander GUI

$ R
> library(Rcmdr)
Loads packages
> Commander()

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/

Posted by kkwaiser at 10:01 AM | Comments (0)

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.

Posted by kkwaiser at 03:45 PM | Comments (0)