jeudi 25 avril 2019

Replacing an if statement's condition character with a variable

This is probably an easy one.

In R, can I replace an if condition character (such as >) with a character and execute the if statement with it?

For example, if the if statement is:

ifelse(1 < 2, "T", "F")

But I'm getting the > condition character through a variable:

cc <- ">"

How would I write:

ifelse(1 < 2, "T", "F")

replacing < with cc?

Aucun commentaire:

Enregistrer un commentaire