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,250 points
4,338 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,090 points

Related Questions In Data Analytics

+1 vote
1 answer

Try catch in R

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

answered Nov 6, 2018 in Data Analytics by Kalgi
• 52,350 points
659 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
• 52,350 points
690 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,840 points
1,008 views
+4 votes
0 answers

R programming Error: Error in if (d >= 0) { : missing value where TRUE/FALSE needed

Here is my code: for(i in 1:(nrow(moon_sub))){   l_df[i,] <- ...READ MORE

Jun 24, 2020 in Data Analytics by Molly
• 160 points
1,025 views
0 votes
1 answer

Big Data transformations with R

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

answered Dec 18, 2017 in Data Analytics by Sudhir
• 1,570 points
1,030 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,660 points
1,178 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,660 points
5,890 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

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

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,660 points
1,112 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 6, 2018 in Data Analytics by kappa3010
• 2,090 points
1,701 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP