Vectors बनाना
एक vector values की एक line है जो same kind की साथ store हैं, एक string पर same-colored beads की एक row की तरह। यह R में सबसे basic container है।
In this page:
Syntax
vector_name <- c(value1, value2, value3)
vector_name <- 1:10
vector_name <- seq(from, to, by = step)
Vectors बनाना
एक vector R की सबसे fundamental data structure है -- values का एक ordered collection जो सब same type share करते हैं। x <- 5 जैसी एक single value भी technically length 1 का एक vector है।
Vectors वह building block हैं जिनसे R की दूसरी data structures, जैसे matrices और data frames, built हैं।
Note:
R में लगभग सब कुछ एक vector है, scalars भी -- कोई separate single-value type नहीं है।
उदाहरण: Creating Vectors
x <- 5
y <- c(1, 2, 3, 4, 5)
cat(length(x), length(y), "\n")
print(y)
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. #}
आम गलतियां
cके बिनाy <- (1, 2, 3)लिखना, जो एक syntax error है।- यह उम्मीद करना कि
x <- 5जैसी एक single value एक vector से अलग होगी, जब R में यह length 1 का एक vector है। c(1, "a")जैसे types mix करना और यह देखकर surprised होना कि सारे elements characters बन जाते हैं।
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: