Skip to content

Instantly share code, notes, and snippets.

@DrNickRedfern
Last active September 8, 2022 10:16
Show Gist options
  • Save DrNickRedfern/085ed7b804b743abc8d68a0db210a6ee to your computer and use it in GitHub Desktop.
Save DrNickRedfern/085ed7b804b743abc8d68a0db210a6ee to your computer and use it in GitHub Desktop.
An illustration of an ifelse statement in R
a <- 2
if (a > 0){
print(paste0(a, " is a positive number"))
} else if (a < 0) {
print(paste0(a, " is negative number"))
} else {
print(paste0(a, " equals zero"))
}
[1] "2 is a positive number"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment