Learn R Programming

NMOF (version 1.2-2)

showExample: Display examples

Description

Display the code examples from ‘Numerical Methods and Optimization and Finance’.

Usage

showExample(file = "", chapter = NULL, showfile = TRUE,
            includepaths = FALSE, ...)
showChapterNames()

Arguments

file

a character vector of length one. See Details.

chapter

optional: a character vector of length one, giving the chapter name (see Details), or an integer, indicating a chapter number. Default is NULL: look in all chapters.

showfile

Should the file be displayed with file.show? Defaults to TRUE. A file will be displayed if only a single file is identified by file and chapter.

includepaths

Should the file paths be displayed? Defaults to FALSE.

Arguments passed to grepl; see Details.

Value

showExample returns a data.frame of at least two character vectors, Chapter and File. If includepaths is TRUE, Paths are included. If no file is found, the data.frame has zero rows. If a single file is identified and showfile is TRUE, the function has the side effect of displaying that file.

showChapterNames returns a character vector of length 15: the names of the book's chapters.

Details

showExample matches the specified file argument against the available file names via grepl(file, filenames, ...). If chapter is specified, a second match is performed, grepl(chapter, chapternames, ...). The chapternames are those in the book (eg, ‘Modeling dependencies’). The selected files are then those for which file name and chapter name could be matched.

References

Gilli, M., Maringer, D. and Schumann, E. (2011) Numerical Methods and Optimization in Finance. Elsevier. http://www.elsevierdirect.com/product.jsp?isbn=9780123756626

Schumann, E. (2016) Financial Optimisation with R (NMOF Manual). http://enricoschumann.net/NMOF.htm#NMOFmanual

Examples

Run this code
# NOT RUN {
showExample("equations.R")

showExample("example", chapter = "portfolio")
showExample("example", chapter = "Portfolio")
showExample("example", chapter = "portfolio", ignore.case = TRUE)
showExample("example", chapter = 13)
showExample("example", chapter = showChapterNames()[13L])

# }

Run the code above in your browser using DataLab