Skip to content

Instantly share code, notes, and snippets.

@MikeMKH
Created August 1, 2017 11:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MikeMKH/401feca0b58945ba12cc61d7d38f66a2 to your computer and use it in GitHub Desktop.
Save MikeMKH/401feca0b58945ba12cc61d7d38f66a2 to your computer and use it in GitHub Desktop.
FizzBuzz kata as a tibble from tidyverse
library(tidyverse)
fb <- tibble(
x = 1:100,
fizzable = ifelse(x %% 3 == 0, TRUE, FALSE),
buzzable = ifelse(x %% 5 == 0, TRUE, FALSE),
formatted = ifelse(fizzable & buzzable, "FizzBuzz",
ifelse(fizzable, "Fizz",
ifelse(buzzable, "Buzz",
x)))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment