An implementation of a SAS datastep in a class
R6Class generator object
i begins at 0 and is incremented for each iteration of the data step.
results frame is initialized as an empty data frame.
It is populated row-wise with each iteration of the data step.
continue is a marker which signals that the step should
continue repeating. When
continue is 1, repetition will continue, and when
continue is 0, repitition will cease. It is initialized to 0.
eval is initialized as NULL, but will store a pointer to
the current evaluation environment. This pointer helps pass the evaluation
environment from one iteration of the data step to the next.
begin does three things: imports the environment of the previous
step to the current, stores the current environment (or the environment specified),
i by 1. It takes one argument,
envir, which should
typically be set to
set takes two arguments: a data frame and an optional unquoted
group_id variable must contain a consecutive sequence of natural
numbers from 1 to some maximum. In each data step, rows where
i matches the
group_id variable (or simply the ith row if no group_id variable is given) are selected,
and the slice is split into vectors and imported into the evaluation environment.
continue is set to 0 once
set reaches the maximum value in the
column, ceasing repetition of the datastep, else
continue is set to 1.
A standard evaluation version of
set_, in which the
variable is included as a string, formula, or lazy object.
output takes an optional list argument. Either the list, or, if none is given,
all vectors in the evaluation environment are gathered into a data.frame, and this data.frame
end will, if
continue is 1, evaluate
the function given within the evaluation environment. Typically, the function
given will be the current function: that is, steps are joined recursively.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
y x 1 2 1 2 3 2 3 4 3 4 5 4 5 6 5 6 7 6 7 8 7 8 9 8 9 10 9 10 11 10
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.