Reformat code function

I like the way RStudio formats R code (Code -> Reformat Code or 'Ctrl + Shift + A'). I would like to apply this a githook or GitHub action, but I cannot find out what command is actually run or how to achieve similar with formatR or Styler.

Any idea what package and command is run behind the scenes or how to replicate this?

For {styler}, you can use the Addin in RStudio and create a keyboard shortcut for it. With GitHub Actions, there is a /style command, I build {precommit} to use {styler} as a git pre-commit hook. All of this is linked in the documentation of {styler}.

Thanks, I might try that. I had used styler but it did not format the code in a nice way like RStudio does.

Can you be more specific about what you did not like? We might be able to improve it (I am the maintainer of {styler})

Hi, thanks for the reply. It may be my lack of understanding as how to customise Styler (if that is possible?). (Please bare with me as my terminology will be off as I come from Python/C) If a list of arguments exceeds the set line width, then styler breaks the line at the most convenient point and starts a new line. RStudio on the other hand breaks at each argument and indents/aligns them. I find this much more readable