barplot() on Numeric Vector

Q

How to use the barplot() function on a numeric vector?

✍: FYIcenter.com

A

barplot() function is provided in the built-in "graphics" package. You don't need to install any external packages to use barplot().

If you have a numeric vector, you can visualize it as a bar chart with the barplot() function.

Call barplot() with on a numeric vector:

> v = c(2,3,4)

> typeof(v)
[1] "double"

> barplot(v)

Call barplot() with on a named numeric vector. The name for each member will be printed below the bar.

> v = c(2,3,4)
> names(v) = c("First", "Second", "Third")

> typeof(v)
[1] "double"

> barplot(v)
barplot() Function on Named Vector
barplot() Function on Named Vector

 

What Is plot() Function

The R Graphics Package

Built-in Graphics Package in R Environment

⇑⇑ R Software Environment - Frequently Asked Questions

2023-05-09, 286🔥, 0💬