我对 R 还不太熟悉,目前正在使用 R derivmkts 包及其 binomopt 函数。该函数输出期权价格和股票价格,这些价格在控制台中以表格形式显示。我如何将这些表格导出到 latex 表格中?代码如下
S=110 K=100, v=0.2, tt=2, d=0, n=12
binomopt(S, K, v, r, tt, d, n, american = FALSE,
putopt=FALSE, specifyupdn=FALSE, crr=TRUE, jarrowrudd=FALSE,
up=1.5, dn=0.5, returntrees=TRUE, returnparams=TRUE,
returngreeks=FALSE)
提前谢谢您!
答案1
\documentclass{article}
\usepackage{booktabs}
\begin{document}
<<results='asis',echo=F>>=
library(derivmkts)
S=110
K=100
v=0.2
tt=2
d=0
n=12
x <- binomopt(S, K, v, tt, d, n, american = FALSE,
putopt=FALSE, specifyupdn=FALSE, crr=TRUE, jarrowrudd=FALSE,
up=1.5, dn=0.5, returntrees=TRUE, returnparams=TRUE,
returngreeks=FALSE)
knitr::kable(x, "latex", booktabs=TRUE)
# For single tables:
#
# knitr::kable(x$stree, "latex", booktabs=TRUE)
# knitr::kable(x$params, "latex", booktabs=TRUE)
# # etc ...
@
\end{document}