Check if the Object is a Matrix in R Programming – is.matrix() Function
Last Updated :
12 Jun, 2020
is.matrix()
function in R Language is used to return TRUE if the specified data is in the form of matrix else return FALSE.
Syntax: is.matrix(x)
Parameters:
x: specified matrix
Example 1:
A < - matrix(c( 1 : 5 ))
B < - matrix(c( 1 : 12 ), nrow = 4 , byrow = TRUE)
C < - matrix(c( 1 : 12 ), nrow = 4 , byrow = FALSE)
is .matrix(A)
is .matrix(B)
is .matrix(C)
|
Output:
[1] TRUE
[1] TRUE
[1] TRUE
Example 2:
x < - BOD
is .matrix(x)
is .matrix( 4 )
is .matrix( "2" )
is .matrix( "a" )
|
Output:
[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
Share your thoughts in the comments
Please Login to comment...