← Back to R Course | Chapter 2: Variables & Types | Lesson 1 of 7

Assignment Operators क्या हैं

Assignment एक value को एक नाम के नीचे store करता है, एक arrow इस्तेमाल करते हुए एक labeled box में एक toy डालने की तरह। R आमतौर पर arrow left की ओर pointing खींचता है।

In this page:

  1. Assignment Operators
Syntax
r
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

markup
x <- 10
y = 20
30 -> z

cat(x, y, z, "\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. -> को ऐसे तरीके से इस्तेमाल करना जो backwards पढ़ा जाए, जैसे 30 -> z, और confuse होना कि कौन-सा side value receive करता है।
  2. एक space के साथ x < - 5 लिखना, जो assignment की बजाय x का -5 से एक comparison है।
  3. एक function call जैसे mean(x = 5) के अंदर = इस्तेमाल करना और एक global variable x बनने की उम्मीद करना, जब यह सिर्फ एक argument set करता है।
🔒

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.