Automatic styling with styleR

The tidyverse style guide provides all the detail you could need on the specifics of styling code. However, applying it manually can be time consuming. Instead, you can use styler, an R package that helps format your code automatically. If you haven’t already installed it, run install.packages("styler").

Once this package is installed (which only needs to be done once), you can use an ‘Addin’ in RStudio. Click the ‘Addins’ button, scroll down to the ‘STYLER’ section and click ‘style active file’.

Image of the RStudio toolbar with the Addins button highlighted.

Image of the RStudio STYLER section of 'Addins'.

Back to top