-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stylistic and code consistency rules #309
Comments
One thing from #310 that might be good: prefer The big one in this PR, though, is |
Suggestion to use
Some good discussion here: https://stackoverflow.com/questions/50646133/dplyr-if-else-vs-base-r-ifelse |
I agree with this and we should add explicit testing to our list (as you changed in #310) Edit: added to the checklist |
@LucyMcGowan can be the tie-breaker for |
Afaik it's not relevant to applications we're using in this book, but Reading from the beginning, this is the first time I've encountered |
Great plan! |
New topic: suggest replacing |
|
@LucyMcGowan voted for |
Note: https://github.com/ropenscilabs/aeolus will auto wrap markdown lines |
This is a sort of internal style guide for various decisions we need to make. All of these are open to discussion, but I want to be consistent for all of them. This issue also serves as a final check when the first edition is done.
Code
grkstyle::grk_style_dir()
to style codetibble()
instead ofdata.frame()
summarize()
instead ofsummarise()
if_else()
instead ofifelse()
group_by()
over.by
.by
orgroup_by()
with.groups = "drop"
instead ofungroup()
. Prefer.by
unlessgroup_by()
is more readable for the code, e.g., a very long or complexsummarize()
statementaugment(data = ...)
vs.augment(newdata = ...)
: For cases when we are supplying the original data frame (which we need to do to keep the variables that weren't in the model), use thedata
argument ofaugment()
instead ofnewdata
.newdata
should only be used when it's actually a new data frame, as we do in g-computation cloning.|>
instead of%>%
slice_sample()
instead ofsample_n()
,sample_frac()
(because it supercedes these per the documentation)#
at beginning0
and1
, e.g. ifx = 1
, writeif (x == 1)
rather thanif (x)
case_when()
, use.default = default_value
rather thanTRUE ~ default_value
Quarto
code-fold: true
overecho: false
. This way, we can de-emphasize the code while providing easy access for those interested`{pkg}`
(which will automatically link to the package website) the first time you mention it in a chapter; thereafter, don't use formatting. Just write: pkg.Writing
Figures and tables
gt()
for code-based tables instead ofkable()
. Otherwise, use markdown tables.I think we may have some other things to add for this one to make sure these are consistent
The text was updated successfully, but these errors were encountered: