Function to check if matrix empty or not

0 votes

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?

Oct 29, 2018 in Data Analytics by Ali
• 11,360 points
2,509 views

1 answer to this question.

0 votes

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)
answered Oct 29, 2018 by Maverick
• 10,840 points

Related Questions In Data Analytics

0 votes
1 answer

How to check if a file already exists or not in R?

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

answered Oct 29, 2019 in Data Analytics by Cherukuri
• 33,030 points
68,178 views
0 votes
1 answer
0 votes
1 answer

Check if number is armstrong number or not

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

answered Sep 30, 2019 in Data Analytics by anonymous
• 33,030 points
1,551 views
0 votes
1 answer

How to check if a directory exists and how to create and create if doesn't exist?

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

answered Apr 17, 2018 in Data Analytics by DataKing99
• 8,250 points
2,600 views
0 votes
1 answer

Check if a matrix is diagonalizable in R Programming Language

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

answered Dec 24, 2018 in Data Analytics by Tyrion anex
• 8,700 points
1,833 views
0 votes
1 answer

Modular programming in R language

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

answered Jan 31, 2019 in Data Analytics by Tyrion anex
• 8,700 points
805 views
0 votes
1 answer

By using dpylr package sum of multiple columns

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

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
2,260 views
0 votes
1 answer

How to convert a text mining termDocumentMatrix into excel or csv in R?

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

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
1,947 views
0 votes
1 answer

Error saying "could not find function "read_html"" when trying to use read_html function

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

answered Nov 21, 2018 in Data Analytics by Maverick
• 10,840 points
4,772 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP