...

/

Introduction to Chart Functions in R

Introduction to Chart Functions in R

Learn the functionalities of chart functions and how to configure them.

Data visualization has numerous benefits, such as identifying patterns and trends that may not be apparent through tabular data. It also helps to make complex data easier to understand and communicate to others, which ultimately leads to faster and more informed decision-making. To reap these benefits, it’s important to learn data visualization in a tool like R. With tools such as ggplot2, R provides a wide range of options for creating high-quality data visualizations. By learning data visualization in R, we can enhance our skills as data analysts and increase our value in the job market.

Built-in functions

The default function for visualization in R is plot(). It is a versatile function that allows for the creation of various types of charts.

With the built-in functions in R, we can create:

  • Line charts and scatterplots with plot()
  • Pie charts with pie()
  • Bar charts with barplot()
  • Histograms with hist()
  • Boxplots with boxplot()

Note: We will use a simple chart to show the configuration options that aren’t chart-specific in this lesson.

Basic function arguments

Before going through all these chart types, it is good to learn about the arguments that these functions commonly take. By using them, we can modify the charts for our needs.

Note: Some charts have unique customization options, which are not mentioned below.

  • type: This specifies the type of plot to be created:

    • The default value is p, which creates scatter plots.
    • l creates line plots.
    • b creates a combination of points and lines.
    • h creates histograms.
    • n creates an empty chart to which we can add layers later.
  • lwd: This customizes the thickness of lines, bars, and histograms. It is an integer number. The thickness increases as the lwd value increases.

  • size: This customizes the size of the geometric objects. They ...