Skip to content

Instantly share code, notes, and snippets.

@nathania
Forked from hadley/ruler.R
Created March 12, 2019 20:31
Show Gist options
  • Save nathania/36bcc974fc147f9a976cc97f2a3823b3 to your computer and use it in GitHub Desktop.
Save nathania/36bcc974fc147f9a976cc97f2a3823b3 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