Creating a Bar Chart in R

Premium

In R, we can create a bar plot using the barplot() function. A Bar Plot or Bar Graph is primarily used to compare values. It presents grouped data using rectangular bars whose lengths are proportional to the values that they represent. Let's take our Product Sales data where we have the Revenue and Gross Margin for each order along with various attributes such as ProductLine, RetailerType, OrderMethod etc. We can use this data to create a bar chart which plots the total or average sales on y-axis as bars and the x-axis as one of these factors that we are interested in such as ProductLine.

Unlock Premium Content

Upgrade your account to access the full article, downloads, and exercises.

You'll get access to:

  • Access complete tutorials and examples
  • Download source code and resources
  • Follow along with practical exercises
  • Get in-depth explanations