Hello,
I am trying to write a function that would format code.
I found the following interesting Stack Overflow Post that goes into how to format certain tokens/operators, but I am trying to specifically format spacing. How do you reference spacing around parentheses to create a new line? In the Stack Overflow post, when printing the as.list(my.call), spaces are not visible, and it is unclear how to format them to me.
Basically trying to add some formatting on top of the in-built formatting or packages that exist. If anyone could explain how to do this that would be very appreciated. In a nutshell, I'd like to understand it. How do you specify when to make a new line? Similar to the formatR package or the in built code formatter (Code -> Reformat Code drop down).
Thank you.
# starting code
data <-
data %>%
group_by(region, category)
# formatted
data <-
data %>%
group_by(
region,
category
)