Arrays क्या हैं
एक array एक matrix जैसा है जिसकी ज़्यादा layers हो सकती हैं, trays के एक stack या cubbies के एक cube की तरह। यह आपको तीन या ज़्यादा directions में data store करने देता है।
In this page:
Syntax
array_name <- array(data, dim = c(rows, cols, layers))
array_name[row, col, layer]
Arrays
R का एक array एक matrix को दो से ज़्यादा dimensions में generalize करता है, array(data, dim = c(...)) से data को एक multi-dimensional grid में store करते हुए।
Elements हर dimension के लिए एक index specify करके access होते हैं, जैसे a[1, 2, 3]। Arrays matrices या data frames से कम commonly इस्तेमाल होते हैं लेकिन genuinely multi-dimensional data के लिए useful हैं।
Note:
एक 2-dimensional array functionally एक matrix जैसा ही है -- matrix() बस एक convenient special case है।
उदाहरण: Arrays
arr <- array(1:24, dim = c(2, 3, 4))
cat("Dimensions:", dim(arr), "\n")
cat("Element at [1,2,3]:", arr[1, 2, 3], "\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. #}
आम गलतियां
- सिर्फ दो numbers से index करना, जैसे
arr[1, 2], जो एक 3-dimensional array के लिए एक error देता है। - यह मान लेना कि पहली dimension columns की संख्या है, जब order rows, columns, फिर layers है।
- ऐसा
dimदेना जिसका product data length से match न हो, इसलिए values cut या recycle हो जाती हैं।
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: