blk.findConsecutive | R Documentation |
Groups of consecutive rows are identified, where each row in the group has a certain property.
blk.findConsecutive(id, ind, min.consec = 2, fill = 0)
id |
A valid |
ind |
A logical vector in |
min.consec |
An integer specifying the minumum size of a group. |
fill |
A value to use when no other value is appropriate. |
This function operates on data sets in block-format
.
Some rows have a certain property as indicated by ind
. This
function identifies groups of rows that all possess the property,
are consecutive and have a minimum size min.consec
. All such
groups of rows identified are assigned a unique integer ID. All
remaining rows are given the value fill
.
An integer vector in block-format
with respect to id
containing a unique group ID for rows belonging to identified
groups, and fill
otherwise.
Benjamin Rich <mail@benjaminrich.net>
block-format
require(nlme)
data(Phenobarb)
dat <- Phenobarb[1:56,] # First 4 subjects
attach(dat)
cbind(dat, CONSEC=blk.findConsecutive(asID(Subject), ind=!is.na(dose), min.consec=5))
detach(dat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.