templateFile | R Documentation |
This function can be used to generate template files for new functions, S4 classes or methods.
templateFile(
name,
path = getwd(),
pck.description = data.frame(Package = "", Author = "", License = "GPL (>= 3)",
stringsAsFactors = FALSE),
year = format(Sys.time(), "%Y"),
params = list(obj = "someClass", ... = "\\code{\\link[somepackage]{somefunction}}"),
seealso = list(aPackage = "aFunction"),
return = list(aPackage = "aFunction"),
type = "function",
write = FALSE,
overwrite = FALSE
)
name |
Character string, name of the function/method/class. |
path |
Full path to the directory where the file should be added if |
pck.description |
Data frame holding the package description. Only the fields "Package", "Author" and "License" are needed/used (see Examples section). |
year |
Character string, the year to use in the copyright information. |
params |
A named list of parameters,
where the element name is the parameter name and its value is the type of object expected as input.
Some objects types are recognized, like "c", "character", "numeric", "logical",
"matrix" or "data.frame".
If an element is called |
seealso |
A named list, where element names define packages and values objects of that package to link. |
return |
A named list, similar to |
type |
Character string, either |
write |
Logical, if |
overwrite |
Logical, if |
Set the parameters to your needs, perhaps setwd
into the target directory,
and set write=TRUE
if you like what you see so far. The result should include a copyright note,
insitial roxygen-style documentation
and some useful first lines of code, guessed from the provided arguments.
If write=TRUE
, writes a file in the path
directory. If write=FALSE
,
returns a character string.
pckg.dscrptn <- data.frame(
Package="SquareTheCircle",
Author="E.A. Dölle <doelle@eternalwondermaths.example.org>",
License="GPL (>= 3)",
stringsAsFactors=FALSE
)
cat(
templateFile(
name="exampleFunction",
pck.description=pckg.dscrptn
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.