- Machine Learning with R Quick Start Guide
- Iván Pastor Sanz
- 122字
- 2021-06-24 16:01:31
Accessing elements in a matrix
You can access the elements in a matrix in a similar way to how you accessed elements of a vector using indexing. However, the elements here would be the index number of rows and columns.
Here a some examples of accessing elements:
- If you want to access the element at a second column and first row:
m<-array(c(1,2,3,4,5,6), dim=c(2,3))
m
## [,1] [,2] [,3]
## [1,] 1 3 5
## [2,] 2 4 6
m[1,2]
## [1] 3
- Similarly, accessing the element at the second column and second row:
m[2,2]
## [1] 4
- Accessing the elements in only the second row:
m[2,]
## [1] 2 4 6
- Accessing only the first column:
m[,1]
## [1] 1 2
推薦閱讀
- Mastering Proxmox(Third Edition)
- DevOps:Continuous Delivery,Integration,and Deployment with DevOps
- Docker High Performance(Second Edition)
- 工業(yè)機(jī)器人操作與編程
- 運(yùn)動(dòng)控制系統(tǒng)
- 中國(guó)戰(zhàn)略性新興產(chǎn)業(yè)研究與發(fā)展·數(shù)控系統(tǒng)
- 貫通Java Web輕量級(jí)應(yīng)用開(kāi)發(fā)
- 新一代人工智能與語(yǔ)音識(shí)別
- FANUC工業(yè)機(jī)器人虛擬仿真教程
- 大數(shù)據(jù)時(shí)代的調(diào)查師
- 天才與算法:人腦與AI的數(shù)學(xué)思維
- Mastering Machine Learning with R
- ASP.NET 4.0 MVC敏捷開(kāi)發(fā)給力起飛
- Arduino創(chuàng)意機(jī)器人入門(mén):基于Mixly
- Artificial Intelligence for Robotics