_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › Matrix

Contents

1 (Matrix)
2 覦覯: cbind(), rbind()
3 覦覯: matrix()
4 覦覯: dim()
5 覦覯: diag()襯 伎 螳,
6 覦覯: upper.tri(), lower.tri()襯 伎 手, 手
7 覦覯: t()襯 伎 豺
8


1 (Matrix) #

  • 2谿 一危 蟲譟
  • 谿, 伎姶 螳讌
  • 螻朱 襴 覓語企 朱Μ 煙 襦 螳讌
  • 螳讌 襭襷 暑

    • (mode)
    • 蠍語(length)
    • 谿(dim)
    • 谿覈(dimnames)

  • 1 2 3
    4 5 6 -> 2 3伎 谿 螳 豺 襦 蠍語企 6

    A D
    B E
    C F -> 3 2伎 谿 螳 覓語 襦 蠍語企 6

2 覦覯: cbind(), rbind() #

> #覯″
> x <- c(1,2,3)
> y <- c(4,5,6)
> z <- c(7,8,9)
> #覦覯1: cbind()襦 企 覿願鍵
> cbind(x,y,z)
     x y z
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9
> #覦覯2: rbind()襦 朱 覿願鍵
> rbind(x,y,z)
  [,1] [,2] [,3]
x    1    2    3
y    4    5    6
z    7    8    9

3 覦覯: matrix() #

> #覦覯3: matrix 蠍
> c(x,y,z)
[1] 1 2 3 4 5 6 7 8 9
> matrix(c(x,y,z), nrow = 3) 
     [,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    5    8
[3,]    3    6    9
> matrix(c(x,y,z), ncol = 3) 
     [,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    5    8
[3,]    3    6    9
> matrix(c(x,y,z), nrow = 3) 
     [,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    5    8
[3,]    3    6    9
> matrix(c(x,y,z), nrow = 3, byrow = T) # 一豈
     [,1] [,2] [,3]
[1,]    1    2    3
[2,]    4    5    6
[3,]    7    8    9
> matrix(c(x,y,z), byrow=T) # 一豈
      [,1]
 [1,]    1
 [2,]    2
 [3,]    3
 [4,]    4
 [5,]    5
 [6,]    6
 [7,]    7
 [8,]    8
 [9,]    9
> matrix(c(x,y,z), ncol = 3, byrow = T) #2覯讌 語 , 伎 蠍磯ゼ 蟆一. 3覯讌 語    一 讌.
     [,1] [,2] [,3]
[1,]    1    2    3
[2,]    4    5    6
[3,]    7    8    9
> 
> matrix(c(x,y,z), ncol = 2, byrow=T)
     [,1] [,2]
[1,]    1    2
[2,]    3    4
[3,]    5    6
[4,]    7    8
[5,]    9    1
> matrix(c(x,y,z), ncol = 1, byrow = T) #企押
      [,1]
 [1,]    1
 [2,]    2
 [3,]    3
 [4,]    4
 [5,]    5
 [6,]    6
 [7,]    7
 [8,]    8
 [9,]    9
> matrix(c(x,y,z), nrow = 1, byrow = T) #覯″
     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
[1,]    1    2    3    4    5    6    7    8    9
> 


4 覦覯: dim() #

> dim(c(x,y,z)) <- c(2,2)
危 dim(c(x, y, z)) <- c(2, 2) : 
  dims [product 4] do not match the length of object [9]
> dim(c(x,y,z)) <- c(3,3)
危 dim(c(x, y, z)) <- c(3, 3) : 
   "c<-"襯 蟆企殊螳 給
> data <- c(x,y,z)
> dim(data) <- c(3,3)
> data
     [,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    5    8
[3,]    3    6    9
> 

5 覦覯: diag()襯 伎 螳, #

> x <- c(1,3,5,0)
> diag(x) #螳
     [,1] [,2] [,3] [,4]
[1,]    1    0    0    0
[2,]    0    3    0    0
[3,]    0    0    5    0
[4,]    0    0    0    0
> diag(1:5)
     [,1] [,2] [,3] [,4] [,5]
[1,]    1    0    0    0    0
[2,]    0    2    0    0    0
[3,]    0    0    3    0    0
[4,]    0    0    0    4    0
[5,]    0    0    0    0    5
> diag(rep(1,3)) #
     [,1] [,2] [,3]
[1,]    1    0    0
[2,]    0    1    0
[3,]    0    0    1
> 

6 覦覯: upper.tri(), lower.tri()襯 伎 手, 手 #

> m <- matrix(1:9, nrow = 3, byrow = T)
> m
     [,1] [,2] [,3]
[1,]    1    2    3
[2,]    4    5    6
[3,]    7    8    9
> upper.tri(m)
      [,1]  [,2]  [,3]
[1,] FALSE  TRUE  TRUE
[2,] FALSE FALSE  TRUE
[3,] FALSE FALSE FALSE
> lower.tri(m)
      [,1]  [,2]  [,3]
[1,] FALSE FALSE FALSE
[2,]  TRUE FALSE FALSE
[3,]  TRUE  TRUE FALSE
> upper.tri(m) * m
     [,1] [,2] [,3]
[1,]    0    2    3
[2,]    0    0    6
[3,]    0    0    0
> lower.tri(m) * m
     [,1] [,2] [,3]
[1,]    0    0    0
[2,]    4    0    0
[3,]    7    8    0
> upper.tri(m, diag = T) * m #手,  螻煙  螳 豺 朱Μ 螻煙企.
     [,1] [,2] [,3]
[1,]    1    2    3
[2,]    0    5    6
[3,]    0    0    9
> lower.tri(m, diag = T) * m #手
     [,1] [,2] [,3]
[1,]    1    0    0
[2,]    4    5    0
[3,]    7    8    9
> 

7 覦覯: t()襯 伎 豺 #

> #豺:  企 螻 伎 朱  
> a <- 1:9
> A <- matrix(a, ncol=3)
> A
     [,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    5    8
[3,]    3    6    9
> t(A)
     [,1] [,2] [,3]
[1,]    1    2    3
[2,]    4    5    6
[3,]    7    8    9
> 

8 #

蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:52

讌 願 殊 覓企 る 蟆 朱 る所 蠍一 殊瑚. ルレ れ 豺 る 蟆 覲牛 殊企朱 蟆 螻 磯る 譟郁 殊 譟郁讌 蟆企. 讌 ル 企朱 蟆 讌 襷 螳碁 譬 企朱 覩碁 覦蠖覲伎. (蟾伎)