poorly_styled_code: A deliberately poorly styled tidyverse code example

View source: R/poorly_styled_code.R

poorly_styled_codeR Documentation

A deliberately poorly styled tidyverse code example

Description

Returns a long chunk of R/tidyverse code that has intentionally inconsistent formatting, spacing, and indentation. It is designed for use in demonstrations of code style tools such as styler::style_text() or styler::style_file().

Usage

poorly_styled_code()

Details

The code:

  • Loads dplyr, ggplot2, and stringr.

  • Performs grouping, summarisation, filtering, joining, and plotting on the built-in mtcars dataset.

  • Is deliberately badly formatted (inconsistent spacing, misaligned pipes, poor indentation, inconsistent line breaks).

The output is meant to provide an example input for automatic code formatting tools, so that users can compare the before (poor style) and after (styled) versions. The code is only returned, never run.

Value

A character vector of class psychdsish_code, with one element per line of code. Printing it shows the code in the console; it can be passed directly to styler::style_text() or written to a file with writeLines().

See Also

styler::style_text(), styler::style_file()

Examples

# Show the messy code
code <- poorly_styled_code()
code

# Pass it to styler to see how formatting improves
styler::style_text(code)


psychdsish documentation built on Nov. 29, 2026, 5:07 p.m.