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
• 10,400 points
30 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,040 points

Related Questions In Data Analytics

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,130 points
24 views
0 votes
1 answer

How to check if object is defines in R?

You can use the exists function for ...READ MORE

answered Nov 6, 2018 in Data Analytics by Kalgi
• 40,420 points
28 views
0 votes
1 answer

Check palindrome or not in R

Hi, I found this code simple and easy. is_palindrome ...READ MORE

answered Aug 20 in Data Analytics by anonymous
• 25,660 points
12 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,270 points
29 views
0 votes
1 answer

Modular programming in R language

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

answered Jan 31 in Data Analytics by Tyrion anex
• 8,270 points
21 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,700 points
93 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,700 points
109 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(“ ...READ MORE

answered Nov 20, 2018 in Data Analytics by Maverick
• 10,040 points
211 views