adplus-dvertising
frame-decoration

Question

Which of the following is valid syntax for if else statement in R?

a.

if(<condition>) {
## do something
}
else {
## do something else
}

b.

if(<condition>) {
## do something
}
elseif {
## do something else
}

c.

if(<condition>) {
## do something
}
else if {
## do something else
}

d.

if(<condition>) {
##& do something
}
else {
##@ do something else
}

Answer: (a).if(<condition>) {
## do something
}
else {
## do something else
}

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Which of the following is valid syntax for if else statement in R?