Get or Set Dimensions of a Matrix in R Programming – dim() Function
dim()
function in R Language is used to get or set the dimension of the specified matrix, array or data frame.
Syntax: dim(x)
Parameters:
x: array, matrix or data frame.
Example 1:
Output:
Time demand
1 1 8.3
2 2 10.3
3 3 19.0
4 4 16.0
5 5 15.6
6 7 19.8
[1] 6 2
Example 2:
x < - rep( 1 : 9 )
x
dim(x) < - c( 3 , 3 )
x
|
Output:
[1] 1 2 3 4 5 6 7 8 9
[, 1] [, 2] [, 3]
[1, ] 1 4 7
[2, ] 2 5 8
[3, ] 3 6 9
Last Updated :
04 Jun, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...