SweaveListingUtils (version 0.1.1)

copySourceFromRForge: copySourceFromRForge

Description

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

Usage

copySourceFromRForge(PKG, TYPE, FILENAME, PROJECT, from, to,
                                 offset.before = 0, offset.after = 0,
                                 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
single character or single numeric or missing; if character, the starting string being searched (by grep, hence as regular expression); if numeric, the starting line number, if missing we begin with the first line of the file
to
single character or single numeric or missing; if character, the ending string being searched (by grep, hence as regular expression); if numeric, the ending line number, if missing we end with the last line of the file
offset.before
numeric; number of lines to be included before the first match; defaults to 0
offset.after
numeric; number of lines to be included after the first match; defaults to 0
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

Value

  • the character content of the filtered source file, if nothing is found it returns invisible().

Details

produces a vector of characters where each component is one line of the original source file; arguments from, to may be
  • missing
{then the whole file (resp. from the beginning or to the end) is used} numbers{then the limits are just given as line numbers} characters{then file is searched for the first occurrance of a passage framed by from, to; uses grep; hence regular expressions may be used which involves masking of (,{,\, etc. as described in the cited reference; }

Examples

Run this code
copySourceFromRForge("distr","R","AllClasses.R","distr", from =2, to =3,
                     offset.after=2)
copySourceFromRForge("distr","R","AllClasses.R","distr", from ="setClass",
                      to ="}")

Run the code above in your browser using DataCamp Workspace