Did you know that you can change your #quarto theme? You can even create your own theme using CSS and SCSS. Check it out:
https://quarto.org/docs/output-formats/html-themes.html
Day 22 out #30DaysOfCode
"Always err on the side of caution, and simplicity. It’s easier to give people more functionality than it is to take away stuff they’re used to."
I just wanted to share this quote from chapter 12 in https://r-pkgs.org/.
Day 21 out #30DaysOfCode
Did you know that there is a #rstats tidyverse design guide? It covers everything from camelCase vs snake_case to the underlying philosophy. Check it out!
https://design.tidyverse.org/index.html
Day 20 out of #30DaysOfCode
I enjoy staying up to date on my favorite topics #rstats #linux #economics #vim via RSS feeds. One of my favorite RSS clients is the #terminal client newsboat. What is your favorite RSS feeds? How do you find new feeds to follow?
Newsboat: https://newsboat.org/
Day 19 of #30DaysOfCode
#rstats #linux #economics #vim #terminal #30DaysOfCode
Did you know that there are mastodon clients for your #terminal? I use toot to browse Mastodon on my desktop, check it out here:
https://github.com/ihabunek/toot
What is your favorite Mastodon client?
Day 18 out of #30DaysOfCode
Did you know that you can enumerate tables in #quarto? Simply give it a label by inserting:
```
#| label: "tbl-mylabel"
```
In the same #rstats chunk you create the table in. The table will then be both cross-referenceable and enumerated. Learn more here: https://quarto.org/docs/authoring/tables.html#cross-references
Day 17 out of #30DaysOfCode
If you are already an expert #rstats dplyr data wrangler, you should probably tabulate your data with {gt}. {gt} allows you to turn your nice-looking tibbles into {PDF, HTML, DOCX} tables – perfect for #quarto. Learn more about it on their website, https://gt.rstudio.com/.
Day 16 out of #30DaysOfCode
If you live in the #terminal and know how to exit #vim (but stay voluntarily), you should give the email client #mutt a try. Mutt enables you to edit email messages in vim, and send emails directly from the terminal.
Day 15 of #30DaysOfCode
#terminal #vim #mutt #30DaysOfCode
Have you tried creating charts with mermaid in #quarto? Mermaid generates beautiful charts using plain text. I especially like the flow charts or git branch charts. Learn more about it here: https://quarto.org/docs/authoring/diagrams.html
Day 14 of #30DaysOfCode
Did you know that it is relatively easy to create your own #ggplot theme in #rstats? Especially if you frequently change theme options already.
To create your theme:
```
my_theme <- function () {
theme(
...
)
```
Where ... is your theme options[^1]
You are then able to add this to your ggplot `plot`:
```
plot + my_theme()
```
[^1]: https://ggplot2.tidyverse.org/reference/theme.html
Day 13 of #30DaysOfCode
"Crash early" [^1]
Do you check that the input of your #rstats functions are correct? It is often useful to "crash" your function early if the input is incorrect (e.g when a string is provided, but the function relies on numerical values) and provide useful error messages. A useful package to ensure that you crash early is checkmate.
Read more about it here:
https://mllg.github.io/checkmate/articles/checkmate.html
[^1]: https://pragprog.com/titles/tpp20/the-pragmatic-programmer-20th-anniversary-edition/ p.205
Day 11 of #30DaysOfCode
Would you like to document your #rstats functions better, without creating a full-blown package? Docstring enables you to document your functions using roxygen style comments which you can view via ?.
Learn more about it here:
https://cran.r-project.org/web/packages/docstring/vignettes/docstring_intro.html
Day 10 of #30DaysOfCode
"English is just another programming language" [^1]
https://languagetool.org/ is a open source grammar checker I use daily. I just found out that there is a language server for LT, with plugins available for #nvim. This essentially means that you not only can check your code with your LSP, but also the English. This must be especially useful for #quarto, which the ls supports.
Language server:
https://github.com/valentjn/ltex-ls
[^1]: https://pragprog.com/titles/tpp20/the-pragmatic-programmer-20th-anniversary-edition/ p.64
Day 9 of #30DaysOfCode
"English is just another programming language" [^1]
https://languagetool.org/ is a open source grammar checker I use daily. I just found out that there is a language server for LT, with plugins available for #nvim. This essentially means that you not only can check your code with your LSP, but also the English. This must be especially useful for #quarto, which the ls supports.
Language server:
https://github.com/valentjn/ltex-ls whu
[^1]: https://pragprog.com/titles/tpp20/the-pragmatic-programmer-20th-anniversary-edition/ p.64
Day 9 of #30DaysOfCode
Did you know that you can launch "background jobs" in #nvim? This is useful if you want to render a #quarto document or run an #rstats script while working on something else.
To source the open R script:
:tabedit % | terminal Rscript %
To render the open quarto document:
:tabedit % | terminal quarto render %
To create an alias in your init.lua:
vim.cmd("command RScript tabedit % | terminal Rscript %")
Day 8 of #30DaysOfCode
#nvim #quarto #rstats #30DaysOfCode
"Make renaming easy, and do it often" [^1]
Sometimes you realize that your function in a #rstats project might have a bad name. Instead of ignoring the bad name, try using argadd and argdo to replace strings in multiple files with #nvim
:cd /path/to/project
:argadd ./**/*
:argdo %s/old_name/new_name/g
You can also do this with sed or other terminal tools, but I do not know how to exit vim yet.
How do you make renaming easier?
[^1]: https://pragprog.com/titles/tpp20/the-pragmatic-programmer-20th-anniversary-edition/ p.400
Day 7 of #30DaysOfCode
My favorite resource for learning #rstats is https://www.bigbookofr.com/ by @OscarBaruffa.
The book is especially useful since it is not only easy to find new books, but also books related to previous books you already read because of the detailed categorization.
Day 5 of #30DaysOfCode
pak is a fancy package manager for #rstats which is especially useful for Linux users. If you, for example, are unable to install a package due to missing system dependencies, pak will list which ones are missing, unlike install.packages().
Next time you are installing an R package, try installing with pak!
install.packages("pak")
pak::pkg_install("package")
Learn more about pak:
https://pak.r-lib.org/
Day 4 of #30DaysOfCode
If you are like me, you enjoy project-based workflows, But may also enjoy using #rstats in the #terminal via, for example, #nvim. It is unclear how to open project files such as .Rproj or .Rprofile files when using R in the terminal.
To open these "project files", set the working directory to the project folder in the terminal, or nvim, and launch R from there. R will then source the project files of the working directory.
Day 3 of #30DaysOfCode
#rstats #terminal #nvim #30DaysOfCode
httpgd is a very cool #rstats package which enables you to show plots in your web browser. This is useful if you work in #nvim, since the default graphics viewer is very basic. httpgd have all the features you would expect, such as plot history and exporting plots.
Try it:
install.packages("httpgd")
httpgd::hgd()
httpgd::hgd_browse()
plot(cars$speed, cars$dist)
For more info:
https://www.youtube.com/watch?v=i_09TMdc8g8 by @jmbuhr
https://www.youtube.com/watch?v=uxyhmhRVOfw by @brodriguesco
Day 2 of #30DaysOfCode