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?
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
{styler} does not currently support breaking lines at a certain character width, but it's a highly requested feature. The line breaking you see is because of how lines are broken for function calls as specified in the tidyverse style guide. It's non-trivial (I think) to customize {styler} to break lines at a certain width that works in all cases, gives desired outputs and does not cause significant slow-down.