src = c("# a single line of comments is preserved",
"1+1", "", "if(TRUE){", "x=1 # comments begin with at least 2 spaces!",
"}else{", "x=2;print('Oh no... ask the right bracket to go away!')}",
"1*3 # this comment will be dropped!", "2+2+2 # 'short comments'",
"lm(y~x1+x2) ### only 'single quotes' are allowed in comments",
"1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1 ## comments after a long line")
(expr = parse.tidy(src))
parse.tidy(src, keep.blank.line = TRUE)
cat(deparse.tidy(expr))
deparse.tidy(expr, width.cutoff = 50)Run the code above in your browser using DataLab