Skip to content

Instantly share code, notes, and snippets.

@lcolladotor
Created March 14, 2025 14:48
Show Gist options
  • Save lcolladotor/873005a610b64936f3c9ca3e27202416 to your computer and use it in GitHub Desktop.
Save lcolladotor/873005a610b64936f3c9ca3e27202416 to your computer and use it in GitHub Desktop.
Examples of R code that is not correctly formatted
# Bad examples from https://style.tidyverse.org/syntax.html
x[,1]
x[ ,1]
x[ , 1]
# Bad
mean (x, na.rm = TRUE)
mean( x, na.rm = TRUE )
# Bad
if(debug){
show(x)
}
# Bad
max_by <- function(data, var, by) {
data |>
group_by({{by}}) |>
summarise(maximum = max({{var}}, na.rm = TRUE))
}
# Bad
height<-feet*12+inches
mean(x, na.rm=TRUE)
## Example from https://posit-dev.github.io/air/formatter.html
list(
foo, bar)
data |>
select(foo) |> filter(!bar)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment