Closed cboettig closed 12 years ago
Good points; formatR conforms to the rule of braces too; it will even forcibly move a line started by else
back to the last line ended by }
. For the line width, you can tune it by options(width)
or use the width.cutoff
argument. I do not want to fix it to 80 because in some cases 80 is still too wide, so I let the user adjust the width using the global option.
One thing that is not consistent with Hadley's style is the indentation by 2 spaces (formatR uses 4). Actually now I prefer 2 spaces, so I may consider implementing it in the future.
Google also has a published style for R code. http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html
Great package. It would be quite nice to use this to check/make code conform to a standard style guide for R, such as Hadley's recommendations. Some of these might just trigger warnings that the user could fix manually.
It's nice to see that the changes you implement are consistent with those recommendations, might be a selling point for the package. Looks like the package focuses on spacing, but would be cool to have it enforce line length and brace habits as well. I suppose ideally these would be options you could include,eg tidy("mycode.R", spaces=T, braces=T, linelength=T, ..,)
anyway, brilliant work.