Utility functions for handling book examples

Share:

Description

Utility functions for returning a list of the included examples and displaying, executing, saving and editing the example codes are provided.

Usage

1
2
3
4
5
listEx()
showEx(Example)
saveEx(Example)
editEx(Example, ...)
runEx(Example, ...)

Arguments

Example

Characater, the name of the example as contained in listEx().

...

Ellipsis argument. See details.

Details

The ellipsis arguments in the function editEx() are passed down to the function file.edit(). If the option editor is unset and/or a different editor shall be employed for openening the example code, then the ellipsis argument can be utilised by editor = "foo", wherey foo is the name of the editor to be used.
The ellipsis arguments in the function runEx() are passed down to the function source().

Value

listEx
Returns a character vector of the examples' names.
showEx
Returns the example of of Example to the console.
saveEx
Returns a logical whether the saving of the R code example into the working directory was successful.
editEx
Opens a copy of the example code in an editor.
runEx
Executes the example code.

Author(s)

Bernhard Pfaff

See Also

file.edit, source

Examples

1
2
3
4
5
6
7
8
9
  
## Not run: 
listEx()
showEx(Example = "Part1Chapter3Ex2")
saveEx(Example = "Part1Chapter3Ex2")
runEx(Example = "Part1Chapter3Ex2", echo = TRUE)
editEx(Example = listEx()[1], editor = "emacs")

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.