R Programming error in if condition

0 votes

I am new to R programming and when I run the below if condition:

if("TRUE") 
print("YES")

I get an error.

I know the logic, it's quite simple, but why am I unable to run this if loop?

Jan 18, 2019 in Data Analytics by Sophie may
• 10,620 points
1,092 views

2 answers to this question.

0 votes

There's a small mistake in your syntax. This should work:

if (TRUE){
  print("YES")
}
answered Jan 18, 2019 by Tyrion anex
• 8,700 points
0 votes

Hi.

Instead of breaking the line add it in the same line as it is a single statement condition.

if("TRUE") print("Yes")
answered Aug 26, 2019 by anonymous
• 33,030 points

Related Questions In Data Analytics

+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,041 views
0 votes
1 answer

"Error in if" while trying to execute simple code in R

This caused non-logical data or missing values passed ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 52,350 points
633 views
0 votes
1 answer

"no applicable method" Error in r programming

This is caused by using an object-oriented ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 52,350 points
2,563 views
+2 votes
1 answer

“subscript out of bounds” Error in r programming

This error is likely to occur when ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 52,350 points
9,584 views
0 votes
1 answer

R programming: loop difference

Use the lubridate package to do this: d$departure ...READ MORE

answered Jan 17, 2019 in Data Analytics by Sophie may
• 10,620 points
915 views
+1 vote
2 answers

How to sort a data frame by columns in R?

You can use dplyr function arrange() like ...READ MORE

answered Aug 21, 2019 in Data Analytics by anonymous
• 33,030 points
1,839 views
+10 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 9, 2018 in Data Analytics by Abhi
• 3,720 points
1,670 views
0 votes
1 answer

How can I perform word stemming in R

The tm package in R provides the stemDocument() function to stem the ...READ MORE

answered Aug 20, 2018 in Data Analytics by Abhi
• 3,720 points
4,582 views
0 votes
1 answer

Check if a matrix is diagonalizable in R Programming Language

On a given matrix, a, the first way ...READ MORE

answered Dec 24, 2018 in Data Analytics by Tyrion anex
• 8,700 points
1,845 views
+1 vote
1 answer

R programming error

Alright, you can either use gsub to match the ...READ MORE

answered Dec 18, 2018 in Data Analytics by Tyrion anex
• 8,700 points
693 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