Matrices क्या हैं
एक matrix same तरह की value की rows और columns का एक grid है, muffins की एक tray या एक chessboard की तरह। आप इसकी row और column से एक value ढूंढते हैं।
In this page:
Syntax
matrix_name <- matrix(data, nrow = rows, ncol = cols)
matrix_name[row, col]
Matrices
एक matrix single type की values का एक two-dimensional collection है, matrix(data, nrow, ncol) से बनाया गया।
Elements m[row, col] से access होते हैं, और दूसरे index को blank छोड़कर पूरी row या column select की जा सकती है, जैसे m[1, ]। Matrices %*% से matrix multiplication जैसे standard linear algebra operations support करते हैं।
Note:
m[1, ] पूरी पहली row select करता है; m[, 1] पूरा पहला column select करता है।
उदाहरण: Matrices
m <- matrix(1:6, nrow = 2, ncol = 3)
print(m)
cat("Element at row 2, col 3:", m[2, 3], "\n")
print(m[1, ])
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. #}
आम गलतियां
- यह उम्मीद करना कि
matrix(1:6, nrow = 2)rows से भरेगा, जब यह column से भरता है जब तक आपbyrow = TRUEset न करें। - index करते वक्त comma भूल जाना, जैसे
m[2], जो एक row की बजाय position से एक element return करता है;m[2, ]इस्तेमाल करें। - ऐसा data देना जिसकी length dimensions में fit न हो, जो सिर्फ एक warning के साथ values recycle करता है।
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: