Blog Archives

Using R: reshape2 to tidyr

December 17, 2017
By
Using R: reshape2 to tidyr

Tidy data — it’s one of those terms that tend to confuse people, and certainly confused me. It’s Codd’s third normal form, but you can’t go around telling that to people and expect to be understood. One form is ”long”, the other is ”wide”. One form is ”melted”, another ”cast”. One form is ”gathered”, the

Read more »

Scripting for data analysis (with R)

July 30, 2017
By
Scripting for data analysis (with R)

Course materials (GitHub) This was a PhD course given in the spring of 2017 at Linköping University. The course was organised by the graduate school Forum scientium and was aimed at people who might be interested in using R for data analysis. The materials developed from a part of a previous PhD course from a

Read more »

Summer of data science 1: Genomic prediction machines #SoDS17

July 9, 2017
By
Summer of data science 1: Genomic prediction machines #SoDS17

Genetics is a data science, right? One of my Summer of data science learning points was to play with out of the box prediction tools. So let’s try out a few genomic prediction methods. The code is on GitHub, and the simulated data are on Figshare. Genomic selection is the happy melding of quantitative and

Read more »

Using R: When using do in dplyr, don’t forget the dot

May 21, 2017
By
Using R: When using do in dplyr, don’t forget the dot

There will be a few posts about switching from plyr/reshape2 for data wrangling to the more contemporary dplyr/tidyr. My most common use of plyr looked something like this: we take a data frame, split it by some column(s), and use an anonymous function to do something useful. The function takes a data frame and returns

Read more »

Mutation, selection, and drift (with Shiny)

May 14, 2017
By
Mutation, selection, and drift (with Shiny)

Imagine a gene that comes in two variants, where one of them is deleterious to the carrier. This is not so hard to imagine, and it is often the case. Most mutations don’t matter at all. Of those that matter, most are damaging. Next, imagine that the mutation happens over and over again with some

Read more »

Using R: a function that adds multiple ggplot2 layers

April 23, 2017
By
Using R: a function that adds multiple ggplot2 layers

Another interesting thing that an R course participant identified: Sometimes one wants to make a function that returns multiple layers to be added to a ggplot2 plot. One could think that just adding them and returning would work, but it doesn’t. I think it has to do with how + is evaluated. There are a

Read more »

Using R: Don’t save your workspace

April 2, 2017
By
Using R: Don’t save your workspace

To everyone learning R: Don’t save your workspace. When you exit an R session, you’re faced with the question of whether or not to save your workspace. You should almost never answer yes. Saving your workspace creates an image of your current variables and functions, and saves them to a file called ”.RData”. When you

Read more »

It seems dplyr is overtaking correlation heatmaps

March 8, 2017
By
It seems dplyr is overtaking correlation heatmaps

(… on my blog, that is.) For a long time, my correlation heatmap with ggplot2 was the most viewed post on this blog. It still leads the overall top list, but by far the most searched and visited post nowadays is this one about dplyr (followed by it’s sibling about plyr). I fully support this,

Read more »

Using R: tibbles and the t.test function

February 12, 2017
By
Using R: tibbles and the t.test function

A participant in the R course I’m teaching showed me a case where a tbl_df (the new flavour of data frame provided by the tibble package; standard in new RStudio versions) interacts badly with the t.test function. I had not seen this happen before. The reason is this: Interacting with legacy code A handful of

Read more »

Balancing a centrifuge

June 11, 2016
By
Balancing a centrifuge

I saw this cute little paper on arxiv about balancing a centrifuge: Peil & Hauryliuk (2010) A new spin on spinning your samples: balancing rotors in a non-trivial manner. Let us have a look at the maths of balancing a centrifuge. The way I think most people (including myself) balance their samples is to put

Read more »

Search R-bloggers


Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)