lstinputSourceFromRForge: lstinputSourceFromRForge

Description Usage Arguments Details Value Author(s) Examples

View source: R/SweaveListingUtils.R

Description

copies lines of a source file (usually ‘.R’ oder ‘.Rd’) from R forge repository

Usage

1
2
3
4
5
6
lstinputSourceFromRForge(PKG, TYPE, FILENAME, PROJECT, from, to,
                         offset.before = 0, offset.after = 0,
                         LineLength = getOption("width"),
                         withLines = ifelse(TYPE=="R", TRUE, FALSE),
                         fromRForge = getSweaveListingOption("fromRForge"),
                         base.url = getSweaveListingOption("base.url"), ...)

Arguments

PKG

character; name of package to be downloaded

TYPE

character; style of the source code — "man" or "R"

FILENAME

character; the name of the source file to be downloaded

PROJECT

character; the name of the R-Forge project

from

vector of characters or vector of numerics or missing; beginnings of the code sniplets; for details see copySourceFromRForge; note that you need to escape meta characters if you use regular expressions, cf. regex.

to

vector of characters or vector of numerics or missing; endings of the code sniplets; for details see copySourceFromRForge; note that you need to escape meta characters if you use regular expressions, cf. regex.

offset.before

numeric; numbers of lines to be included before the code sniplets; defaults to 0

offset.after

numeric; numbers of lines to be included after the the code sniplets; defaults to 0

LineLength

numeric number of characters per line; defaults to getOption("width");

withLines

logical; shall line-numbers be issued

fromRForge

logical; shall code be downloaded from an R-Forge mirror? Defaults to the corresponding global option

base.url

character; base url from where to download the code sniplet

...

further arguments to be passed on to link[base]{grep}

Details

includes [downloaded] code sniplets in ‘.R’ ‘.Rd’ format in some TeX-lstlistings environment; output is issued on stdout, hence included in ‘.Rnw’ file if wrapped to

1
2
3
<< /chunkname/, results=tex, echo=FALSE>>=
 ... R code ...
@

For example

1
2
3
4
5
<<BinomParam, results=tex, echo=FALSE>>=
lstinputSourceFromRForge("distr","man","BinomParameter-class.Rd","distr")
@

<<skew, results=tex, echo=FALSE>>=

lstinputSourceFromRForge("distrEx","R","Skewness.R","distr", from = "\"skewness\", signature\\(x = \"Binom\"", to = "\\}\\)")

1
@

Within ‘.Rd’ code, examples are type-set in ‘.R’ style; vectors are allowed for arguments from, to; lstinputSourceFromRForge uses copySourceFromRForge for download / reading from cache; line numbers in the downloaded source may be printed out

Value

invisible()

Author(s)

Peter Ruckdeschel [email protected]

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
lstinputSourceFromRForge("distr","R","AllClasses.R","distr",
                     "## Class: BinomParameter", "#-")

lstinputSourceFromRForge("distr","R","AllClasses.R","distr",
                     from = "## Class: binomial distribution",
                     to = "contains = \"LatticeDistribution\"", offset.after = 1)
lstinputSourceFromRForge("distr","man","Binom-class.Rd","distr")

lstinputSourceFromRForge("distr","R","BinomialDistribution.R","distr",
                     from = c("## Access Methods", "## wrapped access methods"),
                     to = c("setReplaceMethod\\(\"prob\", \"BinomParameter\"",
                            "size = value\\)\\)") ,
                     offset.after = c(1,1))
lstinputSourceFromRForge("distr","R","BinomialDistribution.R","distr",
                     from = c(8,43,45), to = c(16,53,45))
lstinputSourceFromRForge("distr","R","BinomialDistribution.R","distr",
                     from = c("## Access Methods", "## wrapped access methods"),
                     to = c("setReplaceMethod\\(\"prob\", \"BinomParameter\"",
                            "size = value\\)\\)") ,
                     offset.after = c(1,1))

SweaveListingUtils documentation built on May 30, 2017, 6:29 a.m.