Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
R for Data Science

You're reading from   R for Data Science Learn and explore the fundamentals of data science with R

Arrow left icon
Product type Paperback
Published in Dec 2014
Publisher
ISBN-13 9781784390860
Length 364 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Dan Toomey Dan Toomey
Author Profile Icon Dan Toomey
Dan Toomey
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Bar charts and plots


In this section, I will show you how to generate bar charts and bar plots using R. I think whether you call a particular graphic a bar chart or a bar plot is up to you. There are minor differences between bar charts and bar plots. In both cases, we have bars representing counts; we display them across your graphic. The steps (and results) involved are similar.

Bar plot

R programming allows us to create bar charts in a variety of ways. The standard function in R is the barplot function. The barplot function only requires a list of the heights to be displayed. All of the following parameters are optional.

Usage

The barplot function is used as follows:

> barplot(data)

The various parameters are as follows:

        height, width = 1, space = NULL,
        names.arg = NULL, legend.text = NULL, beside = FALSE,
        horiz = FALSE, density = NULL, angle = 45,
        col = NULL, border = par("fg"),
        main = NULL, sub = NULL, xlab = NULL, ylab = NULL,
        xlim = NULL...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime