Catch integer(0) in R

0 votes

Consider a statement that produces integer(0)

For example:

 a <- which(1:3 == 5)

Which is the safest way of catching this?

Apr 27, 2018 in Data Analytics by DataKing99
• 8,100 points
73 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

R's way of printing a zero length vector(an integer one). So you could test for length 0

length(a)
[1] 0

I suggest you not to use which, and try using the above method

It might be worth rethinking the strategy you are using to identify which elements you want, but without further specific details it is difficult to suggest an alternative strategy.

answered Apr 27, 2018 by kappa3010
• 2,010 points

Related Questions In Data Analytics

0 votes
1 answer

Try catch in R

The most straightforward way is to wrap ...READ MORE

answered Nov 6, 2018 in Data Analytics by Kalgi
• 35,800 points
22 views
0 votes
1 answer

How do I check and catch errors in R

With tryCatch you can handle errors as you want: an.error.occured ...READ MORE

answered Nov 6, 2018 in Data Analytics by Kalgi
• 35,800 points
9 views
0 votes
1 answer

Error sayimg "Executing test function test.should_error ... Timing stopped at: 0 0 0 " in R

In your testthat tests you declare an anonymous function like so: function() ...READ MORE

answered Nov 12, 2018 in Data Analytics by Maverick
• 10,000 points
30 views
+1 vote
1 answer

Need a hadoop engine in backend to run r server

Dear Koushik, Hope you are doing great. The hadoop ...READ MORE

answered Dec 17, 2017 in Data Analytics by Sudhir
• 1,610 points
25 views
0 votes
1 answer

Big Data transformations with R

Dear Koushik, Hope you are doing great. You can ...READ MORE

answered Dec 17, 2017 in Data Analytics by Sudhir
• 1,610 points
27 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,550 points
29 views
0 votes
1 answer

Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,550 points
39 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

The below is the code to perform ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,550 points
65 views
0 votes
1 answer
0 votes
1 answer

How to join two tables (tibbles) by *list* columns in R

You can use the hash from digest ...READ MORE

answered Apr 5, 2018 in Data Analytics by kappa3010
• 2,010 points
37 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.