tidy.source(source = "ugly.R",
file = "pretty.R",
reindent.spaces = 2,
width.cutoff = 72)
The above did not wrap the code at column 72, my output was as follow:
pwr.norm.test(d = (19.4 - 18.4)/2.8, n = 100, sig.level = 0.05, alternative = "two.sided")
pwr.norm.test(d = (18.9 - 18.4)/2.8, n = 200, sig.level = 0.05, alternative = "two.sided")
pwr.norm.test(d = (18.4 - 18.4)/2.8, n = 10000, sig.level = 0.05, alternative = "two.sided")
Did I do it wrongly? Also, there was no space before and after the "/"
sign after formatting. Was that supposed to be correct? Thanks.
width.cutoff
specifies the minimum length at which line-breaking is tried, not the maximum line length. So in this case it won't start trying to line-break until it's already in the middle of the word alternative
. tidy.source
also doesn't split assignments, so it ends up not finding any place to break until the end of the line.
Also, it does appear that tidy.source
doesn't insert spaces before and after slashes - this behaviour appears to be inherited from deparse
, which it uses.