It’s very necessary to have a look at the data source before trying to analyze it.

In this blog, I will share a powerful function ggpairs to implement the purpose.

Package

  • GGaly

  • ggplot2

  • reshape

Data Source

  • tips from reshape package

Load data

1
2
3
4
5
6
library(GGally)
library(ggplot2)
data(tips, package = "reshape")
head(tips)
colnames(tips)
dim(tips)

1

For each column

1
ggpairs(tips, mapping = aes(color = sex))

2

Select interested columns

1
2
3
4
ggpairs(tips, mapping = aes(color = sex), 
        columns = c("total_bill", "time", "tip"), 
        columnLabels = c("Total_Bill(Continuous_variable)", "Time(discrete_variable)", "Tip(Continuous_variable)"),
        title = "Select_column")

3