min, max और range
min, max, और range आपको बताते हैं सबसे छोटा, सबसे बड़ा, और इनके बीच का gap, एक line में सबसे छोटे और सबसे लंबे बच्चों को ढूंढने की तरह। ये बताते हैं कि numbers कितनी दूर फैलते हैं।
In this page:
Syntax
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
values <- c(23, 5, 67, 12, 45)
cat("Min:", min(values), "\n")
cat("Max:", max(values), "\n")
print(range(values))
Login to try C/C++/Java/PHP code in the editor
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. #}
आम गलतियां
range(values)इस्तेमाल करना और range के size की उम्मीद करना, जब यह minimum और maximum return करता है, इनका difference नहीं;diff(range(values))इस्तेमाल करें।- दो vectors पर
max(a, b)call करना और element-wise results की उम्मीद करना, जबpmax()वह करता है। - एक character vector पर
max()इस्तेमाल करना और इसके alphabetically sort होने से surprised होना।
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: