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 in Data Analytics by Sophie may
• 9,530 points
58 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 by Tyrion anex
• 8,270 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 by anonymous
• 26,020 points

Related Questions In Data Analytics

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
• 40,480 points
36 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
• 40,480 points
73 views
0 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
• 40,480 points
1,480 views
0 votes
1 answer

Can we have an if loop inside a for loop in R programming?

You're If loop doesn't have any condition ...READ MORE

answered Dec 21, 2018 in Data Analytics by Sophie may
• 9,530 points
44 views
0 votes
1 answer

R programming: loop difference

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

answered Jan 17 in Data Analytics by Sophie may
• 9,530 points
44 views
0 votes
2 answers

How to sort a data frame by columns in R?

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

answered Aug 21 in Data Analytics by anonymous
• 26,020 points
121 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 Anmol
• 3,620 points
55 views
0 votes
1 answer

How to know the type of an object?

To find the type of an object ...READ MORE

answered Sep 19, 2018 in Data Analytics by Anmol
• 3,620 points
33 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,270 points
30 views
0 votes
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,270 points
26 views