runscript: Run a package script

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/runscript.R

Description

Run a script associated with a particular chapter

Usage

1
2
3
runscript(x, method=c('run', 'copy', 'view', 'show', 'dir'),
          ask = TRUE, fmt="ch%02d.R", package="FinTS",
          subdir="scripts", lib.loc=NULL)

Arguments

x

an object to identify a file in package/subdir via sprintf(fmt, x).

For example, the default 'fmt' translates x = 2 into 'ch02.R'. If no 'x' is specified, a directory of options is provided.

CAUTION: Under some systems like ESS (Emacs Speaks Statistics) under Windows, pop-up menus such as produced by 'runscript()' may not work properly.

method

One of the following:

  • run run the desired script file, similar to demo or example.

  • copy make a copy if the desired script file in the working directory, similar to Stangle(vignette(...)[["file"]]).

  • view display the desired script file on R console but do not execute it.

  • show display the desired script file using file.show

  • dir return the directory showing only the location of the desired script.

Partial matching is allowed.

ask

logical: Should 'par(ask=TRUE)' should be called before graphical output happens from the scruot?

fmt

a format to be used with 'x' in sprintf to create the name of a file in lib.loc/package/subdir.

subdir

subdirectory of package containing a file of the name constructed via sprintf(fmt, x)

package

Name of a package with subdirectory 'subdir'.

lib.loc

NULL or character string identifying the location where 'system.file(subdir, package, lib.loc)' will find the folder containing the file identified via sprintf(fmt, x)

Details

similar to demo or example

Value

the full full path and filename, invisibly unless method == 'dir'

Author(s)

Gabor Grothendieck and Spencer Graves

See Also

demo sprintf system.file package.dir Stangle vignette example

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## Not run: 
# provide a menu
runscript()

# run ~R\library\FinTS\scripts\ch01.R
runscript(1)

# same as:
runscript(1, "run")

# make a copy as 'ch01.R' in the working directory
runscript(1, 'copy')

# display on console only
runscript(1, 'view')

# display using file.show
runscript(1, 'show')

# where is it?
runscript(1, 'dir')

# run ~R\library\nlme\scripts\afda-ch01.R
if(require(fda))
     runscript(1, fmt="afda-ch

## End(Not run)

FinTS documentation built on May 2, 2019, 4:40 a.m.