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,290 points
13 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,000 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,100 points
16 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
• 35,640 points
17 views
+1 vote
1 answer

Custom Function to replace missing values in a vector with the mean of values

You have missed out on "na.rm=TRUE" inside ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,550 points
31 views
0 votes
1 answer
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,280 points
18 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,280 points
16 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
23 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
57 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,000 points
97 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.