← Back to R Course | Chapter 10: Data Visualization | Lesson 3 of 7

barplot() का उपयोग

एक bar plot प्रति category एक bar draw करता है, बड़ी values के लिए लंबे bars, आपके friends की heights compare करने की तरह। यह counts compare करना आसान बनाता है।

In this page:

  1. barplot()
Syntax
r
barplot(heights, names.arg = labels, main = "title")

barplot()

barplot(heights) values के एक vector से (या एक table() result से) एक bar chart draw करता है, प्रति value एक bar, categorical counts या totals compare करने के लिए useful।

names.arg हर bar label करता है। यह categorical/count data visualize करने का standard तरीका है, hist() के उलट जो continuous numeric distributions के लिए है।

Note: barplot(table(x)) एक common combo है: एक categorical vector tabulate करें, फिर सीधे counts chart करें।

उदाहरण: barplot()

markup
sales <- c(Jan = 100, Feb = 150, Mar = 120)

print(sales)
cat("barplot(sales) would draw one bar per month with these heights\n")
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. c("a", "b", "a") जैसा raw data pass करना और एक error पाना, जब counts के लिए आपको barplot(table(x)) चाहिए।
  2. names.arg भूल जाना जब vector के कोई names न हों, इसलिए bars unlabeled रहते हैं।
  3. barplot() को hist() से confuse करना, जब barplot प्रति category एक bar दिखाता है।
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.