paste और paste0
paste text के pieces को साथ glue करता है, train cars को एक train में जोड़ने की तरह। paste0 इसे बीच में बिना space के करता है, और आप अपना खुद का separator चुन सकते हैं।
In this page:
Syntax
paste(string1, string2, sep = " ")
paste0(string1, string2)
paste(vector_name, collapse = ", ")
paste और paste0
paste() strings को साथ concatenate करता है, हर argument के बीच एक separator (default से एक space) insert करते हुए। paste0(), paste(..., sep = "") का shorthand है, बिल्कुल बिना separator के concatenate करते हुए।
दोनों vectors पर भी element-wise काम करते हैं, corresponding elements pair करते हुए।
Note:
paste0(a, b) बिना space के एक string बनाने का एक common shortcut है, जैसे एक file path या identifier।
उदाहरण: paste and paste0
first <- "Hello"
second <- "World"
cat(paste(first, second), "\n")
cat(paste0(first, second), "\n")
cat(paste(first, second, sep = "-"), "\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. #}
आम गलतियां
- यह उम्मीद करना कि
paste("a", "b")में कोई space नहीं होगा, जब default separator एक space है;paste0()याsep = ""इस्तेमाल करें। - एक vector pass करना और एक string की उम्मीद करना, जब
paste()एक vector देता है और आपकोcollapse = ", "चाहिए। - strings जोड़ने के लिए
+इस्तेमाल करना, जो R में एक error है।
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: