Blame | Last modification | View Log | Download | RSS feed
\documentclass[a4paper]{article}\usepackage{listings}\title{Extraction of the source name}\author{Vincent Goulet and R Core Team}\begin{document}\maketitleThis document illustrates usage of the function\texttt{SweaveGetSourceName}. The function may simply be used toprint the name of the file being processed by \texttt{Sweave}.<<>>=SweaveGetSourceName()@The anticipated main use of the function is to launch\texttt{Stangle} inside \texttt{Sweave} without having to hardcode the name of the file in the \texttt{Stangle} call.<<>>=FILE <- SweaveGetSourceName()Stangle(FILE, quiet = TRUE)@This can be used to build documents that rely on artifacts of the\texttt{Stangle} call. For example, we can insert the tangledscript of this file into the document:\lstinputlisting[basicstyle=\small\ttfamily,firstline=3]{%\Sexpr{basename(sub("Rnw$", "R", FILE))}}\end{document}