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,440 points
43 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 file already exists or not in R?

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

answered Oct 29 in Data Analytics by Cherukuri
• 32,260 points
42 views
0 votes
1 answer

Check if number is armstrong number or not

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

answered Sep 30 in Data Analytics by anonymous
• 32,260 points
35 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,130 points
39 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,310 points
54 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,310 points
33 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
128 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
184 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
369 views