i

R Programming Complete Tutorial

ggplot2 Bar Charts

A Bar chart represents data in rectangular bars with a length of the bar proportional to the values of a variable. We use the geom_bar function to create a bar chart.

In this example, we are working with the toothGrowth data frame. In the X and Y axis, we are taking dose and len variables respectively and fill by supp variable. We are generating a bar graph using geom_ bar function.

Example of BAR CHART:

Graph Output:

In this graph output, we can clearly understand that the teeth are growing higher for oj supplement in the case of .5 and 1 ml. But for 2ml UC supplement, teeth are growing highest.