One day late in starting my #rstats 📦 advent calendar, but better late than never!

In this thread, I will every day of December until the 24th post a package I find useful and want you all to know about!

Expect a mix of well-known and lesser know packages!
Dec. 1st - Distill - an #rstats 📦 for creating static webpages, particularly made for scientific and technical communication

Brilliant for making small pages for a single online report or simple personal webpage. Easily hosted through github.

rstudio.github.io/distill/ ImageImage
Dec. 2nd - here

#Rstats Package for file referencing in project-oriented work.

When working in R-projects, {here} makes it easy for your scripts, Rmds etc. to work with relative paths from the project root. Making all your work more portable.

here.r-lib.org ImageImageImage
{here} is brilliant because you can organise your projects in neat folders (eg. data/, scripts/, R/, docs/, results/).
Your files, nested in these folders, can access other files through here::here("data"), or here::here("results"), rather than clumsy paths like "../../data" or non-portable full paths "/entire/path/to/PROJECT/data".
You can then more easily share your project with others, and have it be fully reproducible.
{distill} can help you setup a blog or website containing single articles or full personal webpage.

The online documentation is thorough and easy to follow, showing how the look can be adapted, how to easily add menu items etc.
And on a personal note, the authors are friendly and helpful, and genuinely happy for feedback and user experiences (👀 @apreshill )

And I recently very quickly got a page up with information about my talks and workshops using {distill}

athanasiamo.github.io/talks/ ImageImage
Dec. 3rd - glue #Rstats 📦

An easy & fast string interpreter, to easily combine strings with R expressions for calculation, variables etc.

glue.tidyverse.org ImageImageImage
If you're used to creating long and weird looking paste() or sprintf() to create strings for plots, Rmd's or the like, {glue} offers you a neater (imo) way of creating the strings you are after. ImageImage
It can also conveniently run code on variables directly in the string, so your variables can stay the same, but be displayed in more human readable terms.

And the printed string keeps indentations and linebreaks. ImageImage
{glue} #Rstats 📦 is great for

🤶 creating verbose scripts
🤶 annotating plots
🤶 table captions and annotations
🤶 all your string printing needs! Image
Dec. 4th - holepunch #Rstats 📦

Turn your Rproject into a reproducible project using @Docker and give others the opportunity to launch it using @github and @mybinderteam !

karthik.github.io/holepunch/ ImageImage
The launched project can run a shiny app or launch a RStudio instance in the browser, with all packages and dependencies installed.

This allows people to run your code, replicate and modify your analyses!

For free!
{binder} #Rstats 📦 is one of those packages I want to start using more during 2021. It is a real feat in terms of creating reproducible R work, making it publicly available and easy for people to test your code.
I mean {holepunch} 👆🤦‍♀️
Dec. 5th - xaringan #Rstats 📦

Become a presentation Ninja creating html slides using Rmarkdown.

Xaringan is by far the easiest Rmd to slides creator in #Rstats.

slides.yihui.org/xaringan/#1 ImageImage
After trying other options like beamer and io slides in #Rstats, testing xaringan for the first time was like magic. Learning to use it was so fast, and through knowing a little css I could tweak and create almost any slide configuration I could think of.
In addition to documentation by {xaringan} creator @xieyihui , which is excellent, @apreshill has some awesome slides uncovering even more amazing things you can do with {xaringan} through #RStats
arm.rbind.io/slides/xaringa… Image
I now almost exclusively make my slides through {xaringan} in #Rstats making it even easier for me to put all my content online for other to peruse at their leisure.
{xaringan} #Rstats 📦 is particularly useful if you use it to teach coding, as you can have code and the literal code output side-by-side. Since it's Rmd, it is also almost completely self-contained, and re-knitting will expose any possible functionality change in packages.
All this makes {xaringan} an amazing tool for teaching and keeping up-to-date with the materials you teach _before_ you teach them! :)
Dec. 6th - {usethis} #Rstats 📦

Get your project and packages set-up neatly using customised functions to help you along!

This package is great for package projects, but also for other more general projects, helping you get things organised!

usethis.r-lib.org Image
{usethis} helps you

* add licence files with the `use_[x]_license`
* add github actions with `use_github_action`
* add data, tests, raw-data etc in standardised folders
* add DESCRIPTION, NEWS, vignettes, tutorials and more!
* add package/project dependencies to DESCRIPTION
of my favorite new functions is absolutely the `use_github_action` functions, helping you set up continuous integration check and deployments without the hassle of learning the nit-gritty details of GH actions.

By looking at the auto setups, you can slowly learn more about them
My favourite must be `add_github_action("pkgdown")`, setting up a package check then deployment of a pkgdown site on gh-pages branch automatically. You wont need to remember to update it with new docs, it happens automatically! 😻🤶
The `edit_[x]` functions create easy interfaces to common files to edit for project and user set ups for R

the `ui_[x]` functions are great for making workflows more verbose, and thus also easier to keep track of if running them takes a long time.
and there are just so many gems in {usethis} #rstats package I cannot even mention them all!

I highly recommend installing it and just start perusing the functions in the package:

usethis.r-lib.org/reference/inde…
Dec. 7th - nettskjemar #Rstats 📦

A package to connect to the University of Oslo survey platform "nettskjema". Create an API user, access your survey data, meta-data, and codebooks from R!

lcbc-uio.github.io/nettskjemar/ Image
I am the author of the {nettskjemar} 📦 for #Rstats, and made it out of necessity to easily access data from surveys I have been working on.

Through a series of functions, you can get your online nettskjema data downloaded directly into R, in neat tibbles (data.frame)
This package is particularly useful if your survey has received a lot of responses, as the online portal can get into trouble downloading data with over 2000 responses.

Also, the codebooks and survey meta-data returned from the API is much richer that through the portal.
With the {nettskjemar} #Rstats 📦 you can create a fully reproducible workflow for yourself and colleagues, so you have complete control the entire data processing procedure.
I'm very eager to hear of other using the package, and get ideas on what I could add to make it even better for people to use.
Dec. 8th - {stringr} #Rstats 📦

Do you need to work with character data and are struggling to handle them decently? {stringr} to the rescue! A great string manipulation package.

stringr.tidyverse.org Image
{stringr} #Rstats 📦 has great cheatsheets for helping you figure out what you need, and all the functions start with `str_[x]` so they're easy to find and look through for the version you need.

github.com/rstudio/cheats… ImageImage
The documentation is quite excellent and you should be able to find a function to help you for almost all your needs! ImageImage
{stringr} #Rstats 📦 can, among other things, help you:

🤶 subset strings
🤶 detect & extract patterns
🤶 count characters in strings
🤶 replace string patterns

It's overall a very neat package for string manipulation needs!
Dec. 9th - kableextra #Rstats 📦

Are you creating tables in Rmd with knitr::kable? Spruce them up with the most excellent {kableExtra} addon!

With easy to use and well documented functions, get your tables looking awesome in both PDF and html!

haozhu233.github.io/kableExtra/ Image
{kableExtra} has great #Rstats functions to really make your tables into something awesome.

With a single extra `kable_styling()` on your html table, get an awesome looking bootstrap table out! ImageImage
Or maybe you are working on an academic paper and need more standardised tables? There are great {kableExtra} functions to style your tables into common "classic" ways.
Making it a joy to create #Rstats tables for publication ImageImage
Or maybe you are prepping a table for public dissemination in html format, and need some colour etc to make the information pop?

{kableExtra} has #rstats functions to help you achieve that too! ImageImageImage
You can group columns and rows and just about anything you can think of! ImageImageImage
Overall, {kableExtra} is well worth getting into if you are making tables in both html and latex/pdf, giving you lots of #rstats options to format your tables into nice looking professional tables!
Dec. 10th - Patchwork #Rstats 📦

Create great subplot layouts of your plots!
Patchwork offers a brilliant framework for combining ggplots, base-plots and tables in subplots!

patchwork.data-imaginist.com/articles/patch… Image
Once {patchwork} was revealed to me, I switched immediately, seeing the immense upsides to creating my plots using it! It is extra powerful when plotting ggplot's, but can also combine different grid objects together.

#Rstats ImageImageImage
plot layouts in {patchwork} #rstats are easily set using the plot_layout() function. Or you can use built-in plot combiners:

🤶 + or | -- next to eachoter
🤶 / -- on top of eachother
🤶 () -- to nest subplots ImageImageImageImage
another GREAT feature of {patchwork} is adapting the theme etc in _all_ ggplot subplots of a composition without having to apply it manually to all plots.

Using the & operator before a theme, scale etc will apply it to all plots!

#Rstats Image
You can even inset a plot inside another one! #Rstats Image
and in {patchwork} guides are by default placed where dictated by each plot, but you can easily gather them into a single placement! If the guides/legends are identical between plots, they will be merged into a single one, so no legend duplication!

#Rstats ImageImage
the author, @thomasp85 in general makes awesome packages for visualisation. They should really be checked out!

He also makes amazing generative art, which you should also take a look at!

data-imaginist.com/art
Dec. 11th - {rticles} #Rstats 📦

Are you an academic and working in R? Do you use Rmarkdown?

This package contains templates for _many_ journals, getting your manuscript into better shape for submission!

github.com/rstudio/rticles Image
Getting a manuscript to look and feel like a paper, often gives me more motivation to keep working on something.

And lets face it, journal formatting standards and forcing us to do them prior to 1st submission is tedious and time consuming. {rticles} eases this process!
there is quite some guides to using Rmarkdown out there, and while you might spend lots of time getting used to it in the begnning, once it starts working out, it will pay off.

I do almost everything in Rmarkdown at work.

bookdown.org/yihui/rmarkdow…
And I have been using {rticles} for submissions, making the process of submission a little smoother!

Also, since it's all in Rmd, adding that plot requested from a reviewer is easier. Updating the data and still getting all tables and figures correct is easier.

Worth the it!
Dec. 12th - {forcats} #Rstats 📦

Do you work with categorical data in R? For visualization or statistics, handling categories in R can be quite a challenge. But forcats is an amazing package to help you!

forcats.tidyverse.org Image
There is a great cheatsheet for {forcats} #rstats package that gives you a great overview of what you can do.

github.com/rstudio/cheats… Image
My hands down favourite #rstats {forcats} is fct_lump(), which helps you reduce factor categories to the wanted number, collapsing so that the least frequent end up in an "Other" category. GREAT for plots! ImageImage
and the second is definitely fct_infreq(), which relevels a factor in order of frequency, making it very nice plot creating plots! ImageImage
What if, you just want to move a couple factors a little? In base #rstats, you'd need to provide the factor() with _all possible_ levels in the correct order. with {forcats} fct_relevel() you can specify which you want to move, and where to move them! ImageImageImage
{forcats} #rstats package has saved me hours of recoding, debugging missing levels etc.

Truly recommended!
Dec. 13th - {vitae} #Rstats 📦

Do you need a new resume/cv, but are struggling to create one that looks good? {vitae} is an excellent package for creating lovely resumes through Rmd!

github.com/mitchelloharaw… vitae rstats logo
There are different templates to choose from in {vitae} #rstats packge, like hyndman, and twentyseconds ImageImage
The package also comes with functions to create various entries in the resume, creating a neat interface.

{vitae} i nicely paired with other packages that extract information from online profiles and repositories. ImageImageImageImage
Create awesome resumes with {vitae} #Rstats 📦 My resume made with the vit...
Dec. 14th - {pbmcapply} #Rstats 📦

Do you run a lot of apply'es in R? Do you run them in parallel with mcapply? You might want to track the process with pbmcapply! Get a nice progressbar for your apply.

github.com/kvnkuang/pbmca… Image
I started using this package when developing ggsegExtra, a package for creating new ggseg-compatible altases. This process is a little heavy-handed, and had periods of utter silence doing large'ish parallell jobs. I used pbmcapply to let the user know the process was not stalled.
Having progress bars are great for you and other's that might run your script or functions, if these take a lot of time. Making others aware that there is progress is good. Also, if your process is long and can be run in parallell, give people that option!
Most people have multicore computers, and processing time is halved by running just on two cores. Imagine if people have 8 and can run it on 7!
{pbmcapply} has a great blogpost about its use and performance which is great to check out

It really is a very nice #Rstats 📦 for verbose parallell apply'es!

kevinkuang.net/tracking-progr…
Dec. 15th - {lubridate} #Rstats 📦

Anyone that has worked with date and/or time variables in any program know they are tricky things. lubridate is here to help you manage your date and time objects in R more uniformly! Image
There is are lovely cheatsheets to {lubridate} #Rstats 📦 that you should definintely check out

rawgit.com/rstudio/cheats…

https://t.co/Px8NLHHreG Image
There is too much functionality in lubridate to possibly give you even a tiny fraction of what it can do. But it helps with:

🤶 date-time autodetection
🤶 extraction of date-time information
🤶 rounding and calculations
🤶 durations, periods and intervals
There is a great introductory vignette to the package, also found online.

You _need_ {lubridate} if you are handling date-time objects in #Rstats. It has saved me hours of pain when handling these tricky objects!

lubridate.tidyverse.org/articles/lubri…
Dec. 16h - {magick} #Rstats 📦

Do you feel the need to manipulate raster images from within R? Maybe you need a pipeline to cleanup and add images to plots? {magick} is an excellent package enabling you to do this and so much more!

cran.r-project.org/web/packages/m… Image
Doing neuroimaging, I often have images of brain stuff I want included in my plots. But they usually require some cleaning before they are ready. Removing background, cropping etc. {magick} lets us do all of that from without leaving #Rstats! ImageImageImageImage
There are lots and lots of options shown in the {magick} #Rstats package vignette, with filters, and trimming, and examples of how you can add the images to ggplot2 or base-R plots

cran.r-project.org/web/packages/m…
Of the new really cool features is the possibility of extracting text using OCR and tesseract! Image
Dec. 17th - {papayar} #Rstats 📦

Are you in neuroimaging and working in R, and need a quick way to inspect nifti-images? {papayar} is a great package wrapping the Papaya js viewer!

cran.rstudio.com/web/packages/p…
Just needing a path to a nifti file, {papayar} #rstats package serves a small webpage and using the Papaya js viewer creates a nice interactive little widget to navigate it.

Super easy to use!

And since it's in js, it can easily be embeded in webpages and shiny apps!
Dec. 18th - {learnr} #Rstats 📦

Do you teach R in some way? Do you find it hard to create good exercises that the students can run on their own computers without lots of dependency and system problems? learnr to the rescue!

rstudio.github.io/learnr/ Image
With {learnr} #Rstats 📦 you can create interactive tutorials using Rmd, which can run either on the students RStudio or browser, or that you can host online in RStudio server!

Example tutorial
learnr-examples.shinyapps.io/ex-setup-r/
The brilliance is that text with the problems, code examples, videos and other learning materials can be in integrated directly in the {learnr} #Rstats tutorial, making all content available in the same place, written in the tool you teach!

Ex tutorial:
learnr-examples.shinyapps.io/ex-data-filter/
Since its written i Rmd, it should feel familiar to write the tutorials. ImageImage
The {learnr} tutorials can be bundled within an #Rstats 📦 for your course. By including 📦 in dependencies etc. the student is immediately ready for your course by installing your course package!

My tidyquintro course is an example of this
athanasiamo.github.io/tidyquintro/ Image
Dec. 19th - {janitor} #Rstats 📦

Do you receive or download data to work with and spend hours on cleaning column names etc? {janitor} is the most excellent data cleaning helper I know, saving me hours work!

sfirke.github.io/janitor/ Image
clean_names() is a staple function of mine, cleaning up column names to nicer looking and easier to work with
In addition, I use the remove_empty_columns function after filtering in large data to take away columns that no longer have any valid data. ImageImageImage
{janitor} #Rstats 📦 also comes with several other nifty functions. Like a specialised tabyl() which is a neater version of the base table() function Image
{janitor} #Rstats 📦 offers a nice variety of functions to help you clean your data and get them in ship-shape for you data science needs!
Dec. 20th - {xaringanExtra} #Rstats 📦

I've already mentioned {xaringan} on Dec. 5th, and this package makes that even more awesome! A really cool package that adds great additional features to xaringan slides!

github.com/gadenbuie/xari…
For instance you can make an editable slide! How about getting your audience to list pro's and con's while you write them into the slide live!
or make tabsets within a slide to switch between code, output etc. Creates a nice reveal functionality!
One of my favourites is highlightning code when hovering with the mouse! This is awesome, escpecially when online teaching, making it clear to the audience what line of code you are talking about from https://github.com/gad...
There is great online documentation on {xaringanExtra}
and it really spruces up your xaringan #Rstats slides!

pkg.garrickadenbuie.com/xaringanExtra/…
Dec. 21st - {reactable} #Rstats 📦

Do you make shiny apps, or webpages through R? Maybe you need a cool interactive table for public dissemination of results? reatable is a great package for that!

github.com/glin/reactable/ Image
{reactable} #Rstats package makes it possible to create truly amazing tables, making them more exciting and easy to read for everyone. Not everyone gets thrills by tables with lovely numbers, but colours, icons etc can be of great help!
There are great demos on the package webpage for {reactable} #Rstats package. You should get an idea and instructions for most things there:

glin.github.io/reactable/arti…
I recently used this when I made a small page for the planning of our forest garden. We had created a list of plants and trees we wanted, and I scraped some webcontent to create a nice little overview for us.

athanasiamo.github.io/forestgarden/p…
Dec. 22nd - {broom} #Rstats 📦

If you do statistics in R, which it is actually made to do, you should look into broom! The package comes with lots of awesome features to tidy up model output in R.

broom.tidymodels.org Broom rstats package hex logo
Model outputs in #Rstats can be tricky to work with, but contain lots and lots of information. Extracting what you need for a plot or a table can at times be a struggle. But {broom} makes this so much easier!
In {broom} #rstats package you can

🤶 summarize information about model components with tidy()
🤶 report information about the entire model with glance()
🤶 add informations about observations to a dataset with augment()
tidy() from the {broom} #Rstats package is likely one of my most used non-data wrangling functions.
It very easily grabs what is usual information to add to a statistics table for a paper. Combined with a knitr::kable() in an Rmd, you have a reproducible model table! ImageImage
Dec. 23rd - {rio} #rstats 📦

Need to import data from many different formats and struggle with finding a tool to help you? {rio} is the swiss-army knife of data import and export in R.

SPSS, excel, feather, you name it, it can handle it!

cloud.r-project.org/web/packages/r… Image
On of the great things with {rio} #rstats package is that for text-files, it does not rely in file extension, but the actual data to determine delimiter using data.table::fread. Making fast and stable. Image
exporting data with rio is easy, using the export function

Based on file extension is will know what to save it as. Image
for multi-sheet excel books, rio also has a lovely import_list function, that will import all sheets as a named list. Image
so {rio} #Rstats package is something for you if you'd like a tool that can easily handle many different formats for import and export easily.
Dec. 24th - {pkgdown} #Rstats package

Do you make R-packages and host them online (like on github, gitlab or bitbucket)? pkgdown helps you set up package documentation online, so function documentation, vignettes etc are easily accessible online!

pkgdown.r-lib.org Image
Having package documentation online not only makes it more accessible, examples can be rendered to show expected output and users can see examples _before_ installing the package!

It also makes your package turn up in more online searches.
Be in your 📦 #rstats project in RStudio, and run pkgdown::build_site(), and the static webpages with your docs will be rendered in a `docs` folder. You can then set, for instance in GitHub pages, the site to hosted online from there.
The real amazing stuff happens when paired with usethis.

usethis::use_github_action("pkgdown") will create a GH action that will check your package, install it and pkgdown and deploy the static pages in the gh-pages branch upon pull to master. No need to remember to update!
It's a really great package to create nice user friendly documentation pages. The pkgdown online docs are ofcourse made with pkgdown, and there is lots of great information on customizing your pages!

pkgdown.r-lib.org/articles/index…

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Athanasia Mowinckel

Athanasia Mowinckel Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @DrMowinckels

30 May 20
there is a whole 12-page "expose" on how horrible #mecfs patients are from the view of the researchers and scientists in the CBT/GET camp. It is horrendeous. They completely get to tell their narrative... 1/
and never get properly confronted by the fact that they are the _minority_ in the international ME field, their research is so poor it tells ut nothing, and the little their research tells us usually actually is the opposite of what they claim. 2/
They are in their own echo-chamber when it comes to their research. They only collaborate with and attend conferences with others having their same view. They never attend the largest conference for #mecfs, only the small ones sharing their hypotheses 3/
Read 12 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!