Open lorenzwalthert opened 3 years ago
Do you have any examples?
I applied styler to the 2020 posts in https://github.com/lorenzwalthert/tidyverse.org/commit/d861f38d6440c69314abe350726df768d5d0b622, but the diff is not so useful since it mostly contains end of line space formatting and other artifacts.
Reviewing the last 18 posts superficially manually, here is what I found:
I think the most prominent example is with indention and line breaks:
model <-
nearest_neighbor(neighbors = tune(), weight_func = tune(),
dist_power = tune()
https://www.tidyverse.org/blog/2020/11/tidymodels-sparse-support/
wide_reviews <- tidy_reviews %>%
select(product, word, tf_idf) %>%
pivot_wider(names_from = word, names_prefix = "word_",
values_from = tf_idf, values_fill = 0)
https://www.tidyverse.org/blog/2020/09/usemodels-0-0-1/
impairment_spec <-
boost_tree(trees = tune(), min_n = tune(), tree_depth = tune(), learn_rate = tune(),
loss_reduction = tune(), sample_size = tune())
Or things like
glmnet_grid <- tidyr::crossing(penalty = 10^seq(-6, -1, length.out = 20), mixture = c(0.05,
0.2, 0.4, 0.6, 0.8, 1))
in https://www.tidyverse.org/blog/2020/09/usemodels-0-0-1/
Then, there is minor ones like
1 %>% identity() %>% invisible() %>% identity()
in https://www.tidyverse.org/blog/2020/11/magrittr-2-0-is-here/ and others.
Obviously the world has bigger problems, but implementing one of my suggestions seem a reasonable cost/benefit ratio. In addition, when authors know styling is taken care of, they can spend their attention on the text and what the code does, not what it looks like.
I have noted a few times that code in articles does not correspond to the tidyverse style guide. I can't find any note on the style guide to use in the
README.md
either. I think we could improve on coding style in various ways:{styler}
.tidy = 'styler'
in R code chunks in.Rmd
files or set in the first chunk for all subsequent R chunks, i.g.knitr::opts_chunk$set(tidy = 'styler')
.index.Rmd
template that is created withhugodown::use_tidy_post("short-name")
(not sure the issue should be transferred to the{hugodown}
repo then).