Skip to content

Instantly share code, notes, and snippets.

@DrNickRedfern
Created September 8, 2022 08:52
Show Gist options
  • Save DrNickRedfern/a7b78d83556e166c0f7ef44a15e0a53f to your computer and use it in GitHub Desktop.
Save DrNickRedfern/a7b78d83556e166c0f7ef44a15e0a53f to your computer and use it in GitHub Desktop.
An illustration of an if statement in R
# 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