Created
March 14, 2025 14:48
-
-
Save lcolladotor/873005a610b64936f3c9ca3e27202416 to your computer and use it in GitHub Desktop.
Examples of R code that is not correctly formatted
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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