Created
September 8, 2022 08:52
-
-
Save DrNickRedfern/a7b78d83556e166c0f7ef44a15e0a53f to your computer and use it in GitHub Desktop.
An illustration of an if statement in R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The code in the braces is run when the condition is true | |
a <- 2 | |
if (a > 0) {print("positive")} | |
[1] "positive" | |
# The code in the braces is NOT run when the condition is false | |
b <- -3 | |
if (b > 0) {print("positive")} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment