help(plot)
help(mtcars)2 Introduction
2.1 Introduction
This is the first chapter of Data Visualization With R. The objective of the book is to provide a gentle introduction to working with base graphics in R.
- what is data visualization
- why visualize data
- understand R graphics system
- graphics
- ggplot2
- lattice
- build some simple plots
2.2 What is data visualization?
In simple words, data visualization is the representation of data in graphical format.
2.3 Why visualize data?
- Explore: Visualization helps in exploring and explaining patterns and trends
- Detect: Patterns or anomalies in data can be detected by looking at graphs
- Make sense: Possible to make sense of large amount of data efficiently and in time
- Communicate: Easy to communicate and share the insights from data
2.4 R Graphics System
- graphics
- ggplot2
- lattice
2.4.1 Graphics
- It is part of base R and is the fundamental package for visualizing data.
- It has a lot of good features and we can create all the basic plots using it.
2.4.2 ggplot2
ggplot2, created by Hadley Wickham, is based on the Grammar of Graphics written by Leland Wilkinson. It has a structured approach to data visualization and builds upon the features available in the Graphics and Lattice packages.
2.4.3 Lattice
The lattice package is inspired by Trellis Graphics and created by Deepayan Sarkar. It is a very powerful data visualization system with an emphasis on multivariate data.
2.5 Getting Help
Use the help() to learn more about plot() function and mtcars data set.
2.5.1 mtcars
2.5.2 Variable Info
2.6 plot()
Now that we have some idea about the data set, let us explore the plot() function. We will use the following different data inputs and observe the kind of plots that are generated:
- Case 1: 1 continuous variable
- Case 2: 1 categorical variable
- Case 3: 2 continuous variables
- Case 4: 2 categorical variables
- Case 5: 1 continuous and 1 categorical variable
- Case 6: 1 categorical and 1 continuous variable