Skip to content

Instantly share code, notes, and snippets.

@hadley
Created August 28, 2018 21:57
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hadley/a4a74376e6809592f2486a96a3d2ffad to your computer and use it in GitHub Desktop.
Save hadley/a4a74376e6809592f2486a96a3d2ffad to your computer and use it in GitHub Desktop.
ruler <- function(width = getOption("width")) {
x <- seq_len(width)
y <- dplyr::case_when(
x %% 10 == 0 ~ as.character((x %/% 10) %% 10),
x %% 5 == 0 ~ "+",
TRUE ~ "-"
)
cat(y, "\n", sep = "")
cat(x %% 10, "\n", sep = "")
}
ruler()
#> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+
#> 123456789012345678901234567890123456789012345678901234567890123456789012345
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment