R Programming: matrices

0 votes
I'm using a function that returns a matrix. I would like to see if the matrix is empty or not. How do I check this in R specifically for a matrix?

Any integer can be initialized by using z <- NULL . How can the same be done for a matrix?
Dec 17, 2018 in Data Analytics by Tyrion anex
• 8,330 points
39 views

1 answer to this question.

0 votes

Try this, It will test if a matrix x has zero length:

length(x) == 0

You can initialize a matrix by doing this:

m <- matrix(, 0, 0)

Similarly, this initializes the matrix as 1x1 containing NA:

m <- matrix()

answered Dec 17, 2018 by Sophie may
• 9,920 points

Related Questions In Data Analytics

0 votes
2 answers

What are the rules to define a variable name in R programming language?

The same rules almost follow for all ...READ MORE

answered Aug 26, 2019 in Data Analytics by anonymous
• 32,440 points
151 views
0 votes
1 answer

Why should I adopt R programming

R Programming is the best mechanism for ...READ MORE

answered Oct 29, 2018 in Data Analytics by Maverick
• 10,800 points
37 views
0 votes
2 answers

Error: could not find function - R Programming

Yes, Just like @Maverik said, It happens ...READ MORE

answered Aug 22, 2019 in Data Analytics by anonymous
• 32,440 points
7,319 views
0 votes
1 answer

R programming Web Scraping

Try something like this: library(rvest) library(rvest) library(tidy ...READ MORE

answered Oct 29, 2018 in Data Analytics by Maverick
• 10,800 points
152 views
+9 votes
3 answers

Which is a better initiative to learn data science: Python or R?

Well it truly depends on your requirement, If ...READ MORE

answered Aug 8, 2018 in Data Analytics by Anmol
• 3,680 points
97 views
+1 vote
2 answers
0 votes
1 answer

R programming logic

Use gsub to match the substring that we want ...READ MORE

answered Nov 16, 2018 in Data Analytics by Maverick
• 10,800 points
48 views
0 votes
1 answer
0 votes
1 answer

R programming: Unexpected symbol error

Format your code this way: myfunction <- function() ...READ MORE

answered Dec 17, 2018 in Data Analytics by Sophie may
• 9,920 points
432 views
0 votes
1 answer

Can we have an if loop inside a for loop in R programming?

You're If loop doesn't have any condition ...READ MORE

answered Dec 21, 2018 in Data Analytics by Sophie may
• 9,920 points
57 views