Filed under how to

Scatterplot matrices with ggplot

Scatterplot matrices with ggplot

If you’re constantly exploring data, chances are that you have already used the plot function pairs for producing a matrix of scatterplots. For instance, using the classic iris dataset we can obtain the following graphic data(iris) pairs(iris[,1:4]) You can add colors by simply typing pairs(iris[,1:4], col=iris$Species) If you’re a regular user of the package ggplot2, you might also … Continue reading

5 ways to do some calculation by groups

5 ways to do some calculation by groups

In a previous post I showed  4+1 ways to do some calculation on a quantitative variable that is associated to a qualitative variable. However, there’s another very useful (and powerful) way to do that. Again, I’ll use the same dummy example to calculate the average prices (quantitative) by brands (qualitative) of different products: You should … Continue reading