codeRclub | bioCEED R coding club

May/17

11

Why use ggplot2?

Over the last year or so, I have changed from using base R graphics for all my plots to using ggplot2 for almost everything. I want to show you why. I’m going to use the iris dataset with is available within R. ## Sepal.Length Sepal.Width Petal.Length Petal.Width Species ## 1 5.1 3.5 1.4 0.2 setosa […]

No tags

For most analyses, a large proportion of the code is used to import, reformat and clean the data, and only a small portion is used to run the statistical tests. Despite this, university courses tend to focus on statistical analyses and neglect the data processing steps. Base R (the packages that are automatically installed) has […]

ggplot2 is a very powerful plotting package available in R, but sometimes you just want more: maybe you want to want to make your plots more accessible to colour-blind audiences. Or maybe you just don’t like the included themes. Or maybe you just want more colour in your life like some of the students coming […]

· ·

When data are imported into R it generally arrives as a data.frame, a type of object that contains named columns. We often want to access the contents of each column which can be done with the dollar or square-bracket notation. attach() is used by some R-users to make the columns of a data.frame directly accessible […]

· · · ·

Nov/15

30

Importing excel data into R

Importing data is one of those things that is often much more effort that it should be. It is often convenient to enter data into excel, but this then needs to be imported into R. There are several ways to do this. Probably the worst way to do this is to copy the data from […]

Oct/15

26

Avoid using T to mean TRUE

In R code, it is legal to use T and F to mean TRUE and FALSE respectively. However, TRUE and FALSE are reserved words – they can only be used to mean TRUE or FALSE. Code like will return a syntax error. T and F are not so protected. This means that code like is […]

No tags

Here is a guide for the kind of person who needs to get their data into R and have never done so or are struggling to get their data to load. I’ve tried to explain using simple words and lots of detail – the post is aimed at people who are not comfortable with code, […]

· ·

May/15

21

Progress bars and for loops.

Today somebody asked me about building a progress bar into a for loop. This can be really useful if you are running lots of bootstrapping or Monte Carlo simulations, and you want some peace of mind so that you know that loop is still running as the computer chugs away in the background. It’s good […]

· · ·

In Friday’s codeRclub, we had a problem which involved finding the row and column names for items in a matrix greater than a specified value (e.g. finding the names of the pairs of samples in a  correlation matrix with correlation coefficient greater than 0.5). The problem is that using standard sub-setting methods you are able […]

· · ·

May/15

7

Expressions in R

expression() and related functions including bquote() are powerful tools for annotating figures with mathematical notation in R. This functionality is not obvious from their respective help files. demo(plotmath) nicely shows the huge potential of expression(), but does not help that much with getting the code need for many real cases. I tend to get my […]

· · ·

Older posts >>

Theme Design by devolux.nh2.me