yihui / formatR

Format R Code Automatically
https://yihui.org/formatr/
255 stars 52 forks source link

any way to automatically add braces for single line statement? #56

Open fyears opened 8 years ago

fyears commented 8 years ago

Any way to automatically add braces for single line code inside if or something like that?

For the source code like this:

if (TRUE)
  a = 1
b = 2

Current default result for tidy_source():

if (TRUE) a = 1
b = 2

Expected formatted result (of the requested feature):

if (TRUE) {
  a = 1
}
b = 2
yihui commented 8 years ago

Nope, but if you can figure out how to implement it, I'd be glad to take a look at your pull request :)