Numeric Type क्या है
Numeric R का usual तरह का number है, whole values के साथ-साथ decimals भी hold करने में सक्षम। जब भी आप एक number type करें यह default है।
In this page:
Syntax
x <- 3.14
class(x) # "numeric"
Numeric Type
numeric किसी भी number के लिए R का default type है, values को double-precision floating point की तरह store करते हुए चाहे वे whole numbers जैसी दिखें या नहीं।
R में ज़्यादातर arithmetic numeric results produce करता है। एक value का actual type check करने के लिए class() या typeof() इस्तेमाल करें।
Note:
x <- 5 भी (कोई decimal point नहीं) एक numeric (double) बनाता है, एक integer नहीं, जब तक आप explicitly 5L इस्तेमाल न करें।उदाहरण: Numeric Type
x <- 5
y <- 5.5
cat(class(x), class(y), "\n")
cat(x + y, "\n")
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. #}
आम गलतियां
- यह मान लेना कि
5एक integer है, जब R इसे एक double की तरह store करता है इसलिएclass(5)"numeric"है। - decimals को
==से compare करना, जैसे0.1 + 0.2 == 0.3, जो floating-point rounding की वजह सेFALSEहै;all.equal()इस्तेमाल करें। /से integer division की उम्मीद करना, जब5 / 22.5है और2के लिए आपको%/%चाहिए।
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: