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,130 points
483 views

1 answer to this question.

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,020 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
• 42,330 points
48 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
• 42,330 points
29 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,040 points
60 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
68 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
56 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
76 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
184 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
121 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,020 points
72 views