29282/function-to-check-if-matrix-empty-or-not

I have a function that returns a matrix. I want to check if the returned matrix is empty or not. How do i check it in R? If it is an integer we can check it by is.null(someinteger). But how do we check the same in case of matrices?

here is some question of what is meant by "empty" here but this will test if matrix m has zero length:

length(m) == 0

Regarding initializing a matrix this initializes it to be a 0x0 matrix:

m <- matrix(, 0, 0)

and this initalizes it to be a 1x1 matrix containing NA:

m <- matrix()

and this initializes it to an nr by nc matrix of NA values:

m <- matrix(, nr, nc)

Check out file.exists() function!! The function file.exists() returns a ...READ MORE

Hi Shiva, You need to provide a matrix ...READ MORE

Hey, # take input from the user num = ...READ MORE

You can use showWarnings = FALSE NOTE: showWarnings ...READ MORE

On a given matrix, a, the first way ...READ MORE

R provides support to create subscripts. For ex. ...READ MORE

Basically here we are making an equation ...READ MORE

By assuming that all the values are ...READ MORE

Hey @Ali, Execute the following two commands: install.packages(&l ...READ MORE

Correct the function name. dashboardSidebar() READ MORE

OR

At least 1 upper-case and 1 lower-case letter

Minimum 8 characters and Maximum 50 characters

Already have an account? Sign in.