R 프로그래밍 – 행렬

> matrix(c(1,2,3,4),nrow=2)
     [,1] [,2]
[1,]    1    3
[2,]    2    4
> matrix(c(1,2,3,4),ncol=2)
     [,1] [,2]
[1,]    1    3
[2,]    2    4

#행순서로 데이터들을 나열
> matrix(c(1,2,3,4),ncol=2, byrow=TRUE)
     [,1] [,2]
[1,]    1    2
[2,]    3    4
#열기준 나열
> matrix(c(1,2,3,4),ncol=2, byrow=FALSE)
     [,1] [,2]
[1,]    1    3
[2,]    2    4

> matrix(1:4,nrow=1)
     [,1] [,2] [,3] [,4]
[1,]    1    2    3    4

#행,열 이름 정의
> matrix(1:4,nrow=2, dimnames = list(c("r1","rr2"), c("c1","c2")))
    c1 c2
r1   1  3
rr2  2  4

t() : 인자로 들어간 행렬의 행과열을 뒤집어서 반환
solve() : 행열 몫 구하기
nrow(), ncol() : 행, 열
dim() : 행열

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
모든 댓글 보기
0
생각을 나눠주시면 감사해요!x
()
x
Please enter Google Username or ID to start!
Example: clip360net or 116819034451508671546
Title
Caption
File name
Size
Alignment
Link to
  Open new windows
  Rel nofollow