[[r:r]]

R

R is a Free Open Source Software (FOSS) project implementation of the S programming language. Its a wonderful piece of software (although it has its limitations) but if you're a serious statistician you would ignore learning it at your peril.

Learning R

There are tons of resources out there for learning R. I've collated and categorised those that I've found useful and consider to be of high quality.

Data Management

You'll have to either import data into R or generate data depending on whether you are performing analyses or simulations.

Analysis

There are many analyses that can be performed within R, and the number is growing rapidly as people write and make available extensions. Regardless there are some data manipulation and approaches to analysis that make life a lot easier.

Avoiding Loops

Loops are actually quite slow in R, and where possible the problem should be cast using one of the apply() functions (there are several, mapply(), rapply(), sapply() and lapply()). Personally it took me some time to get my head around using these, and I found A Brief Introduction to apply in R invaluable. There are also other solutions such as some of the helper functions in the plyr package and in a lot of instances using the reshape2 package to melt() the data greatly facilitates the workflow.

Because this is quite a large and varied topic I've split details of to a separate page

Output

R integrates seamlessly with LaTeX using the wonderful Knitr package. Tips and tricks to facilitate common tasks are documented as and when I come across and resolve the problem.

More recently though I've switched to using RMarkdown, which is much more flexible allowing the production of HTML, LaTeX/PDF, M$-Word, and even integrating Shiny to produce dynamic/interactive web-pages.

Graphics

Whilst essentially an output graphics is such a huge area it warrants its own section. There are many options for graphics in R, but they basically fall into two categories lattice graphics or ggplot2. I've opted to dedicate time learning the later, ggplot2 so there won't be much here on lattice.

Programming

Essentially any script written in R constitutes programming, but in this section I go into slightly greater detail about writing functions and keeping related functions grouped together as packages.

There is lots to R programming and unsurprisingly a lot has been written…

Error Messages

If you're anything like me you'll regularly encounter error messages whilst working with R. I have attempted to curate those that I come across along with some of their meanings.

Updating Packages

A neat trick to update all installed packages whenever there is a major release of R is the following code…

install.packages( 
    lib  = lib <- .libPaths()[1],
    pkgs = as.data.frame(installed.packages(lib), stringsAsFactors=FALSE)$Package,
    type = 'source'
)

Installing Manually

Occasionally I've had packages where I've been provided updated versions and I need to install them manually rather than relying on CRAN (since I'm trying to install a version newer than on CRAN). This can be done with…

install.packages('~/path/to/source-file-1.0.1.tar.gz',
                 repos = NULL,
                 type  = 'source')

Shiny

Shiny is an incredibly powerful tool for presenting your work/analyses.

R on Android

A lot of people carry little computers around in their pockets these days (i.e. smartphones and tablets). Wouldn't it be great to have R in your pocket too? Well you can, and I've written up how to do this…Installing R on Android.

Data Sets

Books

Blogs

You only really need to follow one blog to keep abreast of many people who blog about R….

Podcasts

Essentially audio blogs…

r/r.txt · Last modified: 2017/04/25 08:12 by neil
CC Attribution-Noncommercial 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0