"R dim()"의 두 판 사이의 차이

 
(사용자 2명의 중간 판 9개는 보이지 않습니다)
4번째 줄: 4번째 줄:
* 객체의 차원을 조회하거나 설정하는 R 함수
* 객체의 차원을 조회하거나 설정하는 R 함수


<source lang='r'>
<syntaxhighlight lang='r' notebook>
1:6
1:6
## [1] 1 2 3 4 5 6
</syntaxhighlight>
<syntaxhighlight lang='r' notebook>
class( 1:6 )
class( 1:6 )
## [1] "numeric"
</syntaxhighlight>
<syntaxhighlight lang='r' notebook>
dim( 1:6 )
dim( 1:6 )
## NULL
</syntaxhighlight>
</source>
<syntaxhighlight lang='r' notebook=2>
<source lang='r'>
diag(2)
diag(2)
##      [,1] [,2]
</syntaxhighlight>
## [1,]    1    0
<syntaxhighlight lang='r' notebook=2>
## [2,]    0    1
class( diag(2) )
class( diag(2) )
## [1] "matrix"
</syntaxhighlight>
<syntaxhighlight lang='r' notebook=2>
dim( diag(2) )
dim( diag(2) )
## [1] 2 2
</syntaxhighlight>
</source>
<syntaxhighlight lang='r' notebook=3>
 
<source lang='r'>
matrix(1:6, 2, 3)
matrix(1:6, 2, 3)
##      [,1] [,2] [,3]
</syntaxhighlight>
## [1,]    1    3   5
<syntaxhighlight lang='r' notebook=3>
## [2,]    2    4    6
class( matrix(1:6, 2, 3) )
class( matrix(1:6, 2, 3) )
## [1] "matrix"
</syntaxhighlight>
<syntaxhighlight lang='r' notebook=3>
dim( matrix(1:6, 2, 3) )
dim( matrix(1:6, 2, 3) )
## [1] 2 3
</syntaxhighlight>
</source>
<syntaxhighlight lang='r' notebook=3>
<source lang='r'>
m <- matrix(1:6, 2, 3)
m <- matrix(1:6, 2, 3)
m
m
##      [,1] [,2] [,3]
</syntaxhighlight>
## [1,]    1    3   5
<syntaxhighlight lang='r' notebook=3>
## [2,]    2    4    6
dim( m ) <- c(3:2)
dim( m ) <- c(3:2)
m
m
##      [,1] [,2]
</syntaxhighlight>
## [1,]    1    4
<syntaxhighlight lang='r' notebook=4>
## [2,]    2    5
BOD
## [3,]    3    6
</syntaxhighlight>
</source>
<syntaxhighlight lang='r' notebook=4>
dim(BOD)
</syntaxhighlight>


==같이 보기==
==같이 보기==
{{z컬럼3|
* [[R matrix()]]
* [[R matrix()]]
* [[R str()]]
* [[R diag()]]
* [[R diag()]]
* [[R ncol()]]
* [[R ncol()]]
* [[R nrow()]]
* [[R nrow()]]
* [[R dimnames()]]
* [[R dimnames()]]
* [[R 행수 확인]]
* [[R 컬럼수 확인]]
* [[R 행수, 컬럼수 확인]]
* [[NumPy shape]]
* [[Pandas shape]]
}}


==참고==
==참고==
58번째 줄: 65번째 줄:


[[분류: R base]]
[[분류: R base]]
[[분류: R 행렬]]

2021년 10월 3일 (일) 02:34 기준 최신판

1 개요[ | ]

R dim()
  • "dimension"
  • 객체의 차원을 조회하거나 설정하는 R 함수
1:6
class( 1:6 )
dim( 1:6 )
diag(2)
class( diag(2) )
dim( diag(2) )
matrix(1:6, 2, 3)
class( matrix(1:6, 2, 3) )
dim( matrix(1:6, 2, 3) )
m <- matrix(1:6, 2, 3)
m
dim( m ) <- c(3:2)
m
BOD
dim(BOD)

2 같이 보기[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}