Arguments of lm
function can be obtained by using:
args(lm)
Output
function (formula, data, subset, weights, na.action, method = "qr",
model = TRUE, x = FALSE, y = FALSE, qr = TRUE, singular.ok = TRUE,
contrasts = NULL, offset, ...)
NULL
Questions
How to get:
lm (formula, data, subset, weights, na.action, method = "qr",
model = TRUE, x = FALSE, y = FALSE, qr = TRUE, singular.ok = TRUE,
contrasts = NULL, offset, ...)
with the description (Not complete help) of each Argument to be used in Sweave
or knitr
. Thanks
Edited
Using funExtract function provided by @Ananda, I'm very close to my desired result. Here is code of my Rnw
file with output.
\documentclass{article}
\usepackage[T1]{fontenc}
\begin{document}
Arguments for lm
<< label = funExtract, echo = TRUE, results = "hide", tidy = FALSE >>=
funExtract <- function(Function, section = "Usage") {
A <- deparse(substitute(Function))
x <- capture.output(tools:::Rd2txt(utils:::.getHelpFile(help(A))))
B <- grep("^_", x) ## section start lines
x <- gsub("_\b", "", x, fixed = TRUE) ## remove "_\b"
X <- rep(FALSE, length(x))
X[B] <- 1
out <- split(x, cumsum(X))
out <- out[[which(sapply(out, function(x)
grepl(section, x[1], fixed = TRUE)))]]
cat(out, sep = "\n")
invisible(out)
}
@
\vspace{0.5cm}\\
funExtract function output
\vspace{0.25cm}\\
<< label = lm-usage, echo = FALSE, results = "asis" >>=
funExtract(lm, section="Usage:")
@
\vspace{0.5cm}\\
args function output
\vspace{0.25cm}\\
<< label = lm-args, echo = FALSE, results = "asis" >>=
args(lm)
@
\end{document}
Output
Issues with funExtract function output
- How to get highlighted output from funExtract function as other code?
- How to remove section title form funExtract function output?