← Back to R Course | Chapter 9: Statistics | Lesson 2 of 7

min, max और range

min, max, और range आपको बताते हैं सबसे छोटा, सबसे बड़ा, और इनके बीच का gap, एक line में सबसे छोटे और सबसे लंबे बच्चों को ढूंढने की तरह। ये बताते हैं कि numbers कितनी दूर फैलते हैं।

In this page:

  1. min, max, range
Syntax
r
min(x)
max(x)
range(x)

min, max, range

min() और max() एक vector की सबसे छोटी और सबसे बड़ी values return करते हैं, जबकि range() दोनों को एक साथ एक two-element vector की तरह return करता है।

ये simple हैं लेकिन एक dataset की boundaries जल्दी समझने के लिए essential हैं। तीनों numeric और character vectors दोनों पर same तरह काम करते हैं (character comparison lexicographic है)।

Note: range(x), c(min(x), max(x)) का shorthand है एक call में साथ compute किया हुआ।

उदाहरण: min, max, range

markup
values <- c(23, 5, 67, 12, 45)

cat("Min:", min(values), "\n")
cat("Max:", max(values), "\n")
print(range(values))
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. range(values) इस्तेमाल करना और range के size की उम्मीद करना, जब यह minimum और maximum return करता है, इनका difference नहीं; diff(range(values)) इस्तेमाल करें।
  2. दो vectors पर max(a, b) call करना और element-wise results की उम्मीद करना, जब pmax() वह करता है।
  3. एक character vector पर max() इस्तेमाल करना और इसके alphabetically sort होने से surprised होना।
🔒

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.