Assignment Operators क्या हैं
Assignment एक value को एक नाम के नीचे store करता है, एक arrow इस्तेमाल करते हुए एक labeled box में एक toy डालने की तरह। R आमतौर पर arrow left की ओर pointing खींचता है।
In this page:
Syntax
variable_name <- value
variable_name = value
value -> variable_name
Assignment Operators
R conventionally assignment के लिए <- इस्तेमाल करता है, हालाँकि = भी ज़्यादातर contexts में काम करता है।
<- style guides से preferred है क्योंकि यह हर जगह unambiguous है, function calls के अंदर समेत जहाँ = का अलग मतलब है (एक argument को नाम देना)। Right-pointing -> भी valid है और left से right assign करता है।
Warning:
एक function call के अंदर,
f(x = 1) एक named argument set करता है, variable assignment नहीं -- जब आपका actually मतलब assignment से हो <- इस्तेमाल करें।उदाहरण: Assignment Operators
x <- 10
y = 20
30 -> z
cat(x, y, z, "\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. #}
आम गलतियां
->को ऐसे तरीके से इस्तेमाल करना जो backwards पढ़ा जाए, जैसे30 -> z, और confuse होना कि कौन-सा side value receive करता है।- एक space के साथ
x < - 5लिखना, जो assignment की बजायxका-5से एक comparison है। - एक function call जैसे
mean(x = 5)के अंदर=इस्तेमाल करना और एक global variablexबनने की उम्मीद करना, जब यह सिर्फ एक argument set करता है।
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: