tidy.source2 {animation}R Documentation

‘Tidy up’ R Code and Preserve Comments

Description

This function differs with tidy.source merely in this aspect: it preserves comments in complete lines.

Usage

tidy.source2(source = "clipboard", ...)

Arguments

source a string: location of the source code
... other arguments passed to cat, e.g. file

Details

This function helps the user to tidy up his source code in a sense that necessary indents and spaces will be added, etc. See parse. Comments which occupy complete lines will be preserved, but those mixed with code lines will be deleted.

Value

None (invisible `NULL'). `Clean' code will be returned to the console unless the output is redirected by sink.

Author(s)

Yixuan Qiu and Yihui Xie

References

http://animation.yihui.name/animation:misc#tidy_up_r_source

See Also

parse, cat, tidy.source

Examples

## tidy up the source code of image demo 
x = file.path(system.file(package = "graphics"), "demo", "image.R") 
# to console 
tidy.source2(x)
# try tidy.source(x) to see the difference
# to a file
tidy.source2(x, file = tempfile()) 
## check the original code here and see the difference 
file.show(x)

## if you've copied R code into the clipboard 
## Not run: 
tidy.source2("clipboard")
## End(Not run)

[Package animation version 1.0-4 Index]