LineWise-class: Class '"LineWise"'

Description Usage Arguments Objects from the Class Slots Functions and Methods Author(s) See Also Examples

Description

S4 class container for storing R-based code for a workflow step. LineWise class instances are constructed by the LineWise function, based on the R-based code, step name, and dependency tree. When the container is built from the R Markdown, using importWF function, two other slots are populated: codeChunkStart and rmdPath. codeChunkStart will store the first line of each R chunk, and rmdPath will store the R Markdown file path.

Usage

1
2
3
4
## Constructor

LineWise(code, step_name="default", codeChunkStart=integer(), rmdPath=character(), 
        dependency=NA)

Arguments

code

R code separated either by a semi-colon (\;), or by a newline, and enclosed by braces ({ }).

codeChunkStart

integer. R Markdown code chunk line start. This element will be populated when the object is built by importWF.

rmdPath

character. Path of R Markdown file used by importWF.

step_name

character. Step name needs to be unique and is required when appending this step to the workflow.

dependency

logical or character. Dependency tree, required when appending this step to the workflow. Character name of a previous step in the workflow. Default is NA.

Objects from the Class

Objects can be created by calls of the form new("LineWise", ...).

Slots

codeLine:

Object of class "expression" storing R-based code.

codeChunkStart:

Object of class "interger" storing start line from the rmdPath file, when the LineWise is built from R Markdown.

rmdPath:

Object of class "character" storing path from the R Markdown file.

stepName:

Object of class "character" storing step name.

dependency:

Object of class "list" storing dependency tree.

status:

Object of class "list" storing status steps.

files:

Object of class "list" storing file path containing stdout and stderr after running the R-based code.

Functions and Methods

See 'Usage' for details on invocation.

Constructor:

LineWise:

Returns a LineWise object.

Accessors:

codeLine

Printing method for the CodeLine slot.

codeChunkStart

Extract start line of the R Markdown R chunk.

rmdPath

Extract Rmarkdown file path.

stepName

Extract the step name.

dependency

Extract the dependency tree.

status

Extract status of the step.

files

Extract log file path storing stdout and stderr after running step.

appendCodeLine<-

Replacement method for append a R code line.

replaceCodeLine<-

Replacement method for replace a R code line.

Methods:

[

Return a new LineWise object made of the selected R code lines.

[[

Extract the slot information from LineWine object.

[[<-

Replacement method for LineWine slots.

$

Extract slots elements by name.

length

Extract number of R-based code lines.

names

Extract slot names.

show

Summary view of LineWise elements.

coerce

signature(from = "LineWise", to = "list")as(LineWise, "list")

coerce

signature(from = "list", to = "LineWise")as(list, "LineWise")

linewise

Coerce back to list as(LineWise, "list")

Author(s)

Daniela Cassol

See Also

SYSargsList

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
28
29
30
31
32
33
34
35
36
37
showClass("LineWise")
lw <- LineWise(code = {
              log_out <- log(10)
              },
              step_name = "R_log")

codeLine(lw)

## ImportWF option
file_path <- system.file("extdata/spr_simple_lw.Rmd", package="systemPipeR")
sal <- SPRproject(overwrite = TRUE)
# file_path <- "../inst/extdata/spr_simple_lw.Rmd"
sal <- importWF(sal, file_path)
sal <- runWF(sal)
lw2 <- sal$stepsWF[[2]]
lw2
names(lw2)
length(lw2)

## Accessors
codeLine(lw2)
codeChunkStart(lw2)
rmdPath(lw2)
stepName(lw2)
dependency(lw2)
status(lw2)
files(lw2)

## Replacement
appendCodeLine(lw2, after = 0) <- "log <- log(10)"
codeLine(lw2)
replaceCodeLine(lw2, 1) <- "plot(iris)"
codeLine(lw2)

## Coerce
lw2 <- linewise(lw2) ## OR lw2 <- as(lw2, "list") 
lw2 <- as(lw2, "LineWise")

tgirke/systemPipeR documentation built on July 20, 2021, 10:45 p.m.