-
Notifications
You must be signed in to change notification settings - Fork 67
Open
Milestone
Description
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
- Use
grkstyle::grk_style_dir()
to style code - Use
tibble()
instead ofdata.frame()
- Use
summarize()
instead ofsummarise()
- Use
if_else()
instead ofifelse()
- When grouping by a single variable, use
group_by()
over.by
- When grouping by more than one variable when you don't need persistent grouping, use
.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()
statement -
augment(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. - Use
|>
instead of%>%
- Use
slice_sample()
instead ofsample_n()
,sample_frac()
(because it supercedes these per the documentation) - For comments, use all lowercase (except proper nouns) and one
#
at beginning - Use explicit testing of
0
and1
, e.g. ifx = 1
, writeif (x == 1)
rather thanif (x)
- For
case_when()
, use.default = default_value
rather thanTRUE ~ default_value
Quarto
- Prefer cross-references over writing that we discussed/will discuss something somewhere else in the book
- For code we are not showing, prefer
code-fold: true
overecho: false
. This way, we can de-emphasize the code while providing easy access for those interested - Use sentence breaks (a line break after every sentence) for easier git usage. You can do this automatically by changing your settings in RStudio to use sentence breaks and turning visual mode on and off.
- For package names, write it as
`{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
- Check that anytime we type "casual" we mean it. Common typo!
- Defined terms are in bold; italics used for emphasis, not definitions.
- Prefer "exposure" and "outcome" as generic terms for the cause and effect over e.g., treated vs untreated, but use your judgment
- Write it as "Extra Magic Hours" and "Extra Magic Morning/Evening" (all caps)
- Write times as 9 AM instead of 9am
- "data frame" and "data set" (with a space between)
- Consistency with "upweighting" and "downweighting" (one word with no space)
Figures and tables
- All figures and tables have a thorough caption (what is actually in the fig/tbl, not just the idea behind it)
- Use
gt()
for code-based tables instead ofkable()
. Otherwise, use markdown tables. - No time labels for EMM DAG since we don't actually know. Putting this here because we reuse this code in several places so we should check for consistency
I think we may have some other things to add for this one to make sure these are consistent
Metadata
Metadata
Assignees
Labels
No labels