Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in R Programming by (50.2k points)

I am having the following code, but somehow I am not able to execute the code:

asd <- c()

asd1 <- c()

if(asd == asd1)

{

  pr <- 0

} else{

  pr <- 1

}

Error in if (asd == asd1) { : argument is of length zero

I just wanted to know that can we not implement the null values here?

1 Answer

0 votes
by (107k points)

You can use all(), refer to the code:

asd <- c()

asd1 <- c()

if(all(asd == asd1)){

  pr <- 0

} else{

  pr <- 1

}

> pr

[1] 0

If you are a beginner and want to know more about R then do check out the following R programming tutorial.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...