Comments लिखना
एक comment एक hash mark से शुरू होता है और एक note है जिसे R ignore करता है, reader के लिए एक sticky note की तरह। यह बिना बदले बताता है कि आपका code क्या करता है।
In this page:
Syntax
# This is a comment
x <- value # trailing comment
Comments
R में एक # एक comment शुरू करता है, और उस line पर इसके बाद सब कुछ interpreter ignore करता है। R में कोई multi-line comment syntax नहीं है, इसलिए हर comment line को अपना # चाहिए।
Comments को यह clarify करना चाहिए कि code कोई non-obvious चीज़ क्यों करता है बजाय वह दोहराने के जो code से already clear है।
Note:
RStudio और ज़्यादातर editors आपको एक पूरा selected block एक साथ comment/uncomment करने देते हैं, हर line में # add करते हुए।
उदाहरण: Comments
# This script demonstrates comments
x <- 10 # inline comment after code
# print(x) -- this line is commented out and won't run
print(x)
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. #}
आम गलतियां
- comments के लिए
//या/* */इस्तेमाल करने की कोशिश करना, जो R में errors हैं; सिर्फ#एक comment शुरू करता है। - एक single
#से एक block comment करने की कोशिश करना और यह भूल जाना कि हर line को अपना#चाहिए। "a#b"जैसी एक string के अंदर#डालना और सोचना कि यह comment शुरू करता है, जब quotes के अंदर यह ordinary text है।
🔒
Chapter Quiz — Complete all 6 topics to unlock
0/6 topics done
Complete these topics first: