- Hands-On Geospatial Analysis with R and QGIS
- Shammunul Islam
- 211字
- 2021-06-10 18:44:23
Array
Arrays are also like matrices, but they allow us to have more than two dimensions. The all_prices2 row has prices of different items for January, March, and June 2018. Now, suppose we also want to record prices for 2017. We can do so by using array() and in this case we want to add two 3x3 matrices where the first one corresponds to 2018 and the latter matrix corresponds to 2017. In array(m, n, p), m and n stand for the dimensions of the matrix and p stands for how many matrices we want to store.
In the following example, we define six vectors for three different months for two different years. Now we create an array by combining six different vectors using c() and by using them inside array() as inputs as follows:
# Create six vectors
jan_2018 = c(10, 11, 20)
mar_2018 = c(20, 22, 25)
june_2018 = c(30, 33, 33)
jan_2017 = c(10, 10, 17)
mar_2017 = c(18, 23, 21)
june_2017 = c(25, 31, 35)
# Now combine these vectors into array
combined = array(c(jan_2018, mar_2018, june_2018, jan_2017, mar_2017, june_2017),dim = c(3,3,2))
combined
We can now see that we have two matrices of 3 x 3 dimensions, as in the output as follows:

- Mastercam 2017數(shù)控加工自動(dòng)編程經(jīng)典實(shí)例(第4版)
- 工業(yè)機(jī)器人產(chǎn)品應(yīng)用實(shí)戰(zhàn)
- 協(xié)作機(jī)器人技術(shù)及應(yīng)用
- 工業(yè)機(jī)器人入門實(shí)用教程(KUKA機(jī)器人)
- 80x86/Pentium微型計(jì)算機(jī)原理及應(yīng)用
- 工業(yè)機(jī)器人運(yùn)動(dòng)仿真編程實(shí)踐:基于Android和OpenGL
- 筆記本電腦維修90個(gè)精選實(shí)例
- 水晶石影視動(dòng)畫精粹:After Effects & Nuke 影視后期合成
- Mastering Text Mining with R
- Mastering Ansible(Second Edition)
- 傳感器與自動(dòng)檢測
- PowerMill 2020五軸數(shù)控加工編程應(yīng)用實(shí)例
- QTP自動(dòng)化測試實(shí)踐
- Mastering SQL Server 2014 Data Mining
- Learning VMware App Volumes