Learn R Programming

animation (version 0.2-0)

tidy.source: `Tidy up' R code

Description

Actually this function has nothing to do with code optimization; it just returns parsed source code.

Usage

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

Arguments

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

Value

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

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.

See Also

parse, cat

Examples

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

## if you've copied R code into the clipboard 
tidy.source("clipboard")

Run the code above in your browser using DataLab