| RcppExample {RcppTemplate} | R Documentation |
RcppExample illustrates how the Rcpp R/C++
interface class library is used.
RcppExample(params, nlist, vec, mat)
params |
A parameter list specifying method (string),
tolerance (double), maxIter (int) |
nlist |
a list of named numeric values (double or int) |
vec |
a numeric 1D vector (double or int) |
mat |
a numeric 2D matrix (double or int) |
See the document Rcpp: R/C++ Interface Classes: Using C++
Libraries from R for more information. The source files for this example
can be found in the doc package subdirectory.
RcppExample returns a list containing:
nlFirstName |
first name in nlist |
nlFirstValue |
first value in nlist |
matD |
R matrix from an RcppMatrix<double> object |
stlvec |
R vector from a vector<double> object |
stlmat |
R matrix from a vector<vector<double> > object |
a |
R matrix from C/C++ matrix |
v |
R vector from C/C++ vector |
settleDays |
An integer-valued parameter |
price |
A real-valued parameter |
riskFreeRate |
A real-valued parameter |
dividendYield |
A real-valued parameter |
params |
The input parameter list |
Dominick Samperi
# We omit the Date parameters here since this requires QuantLib (see docs)
params <- list(optType='call',
# tradeDate=c(5,15,1998),
# exerciseDate=c(5,17,1999),
settleDays=2,
strikePrice=8,
price= 7,
volatility=0.10,
riskFreeRate=0.05,
dividendYield=0.05)
nlist <- list(ibm = 80.50, hp = 53.64, c = 45.41)
vec <- seq(1,5)
mat <- matrix(seq(1,20),4,5)
result <- RcppExample(params, nlist, vec, mat)
result