Automatic formatting with {styler}
Good coding style is like correct punctuation: you can manage without it, butitsuremakesthingseasiertoread.
This lesson outlines key best practices and introduces a tool for automating their application to your code.
Code formatting: why?
Code formatting might seem like a cosmetic aspect of coding, but it's much more. It's about making code readable, maintainable, and standardizing a style across teams and projects.
If a coworker comes to your desk with a code chunk looking like this, what is your first thought?
cleaNDatA = data %>%
rename(ID = 1,Name = 2 ,Age = 3) %>%
mutate(Age=ifelse(Age < 0, NA, Age)) %>% drop_na() %>%
mutate(Age = as.integer(Age)) %>%
select(-Name)
😳 Confusing isn't it?
While we could write code without adhering to a format, doing so makes understanding and working with the code unnecessarily difficult.
This lesson is for members only! 😔
Become a member now to access the full course with a lifetime access!
Or Login