6.5 Code style

  • What and why: the tidyverse style guide
  • How: the {styler} package
    • styler::style_pkg() restyles an entire R package.
    • styler::style_dir() restyles all files in a directory.
    • usethis::use_tidy_style() is wrapper that applies one of the above functions depending on whether the current project is an R package or not.
    • styler::style_file() restyles a single file.
    • styler::style_text() restyles a character vector.

Make sure you are using version control system before using any of this functions.