prev: Check Some Properties of Vectors

Description Usage Arguments Details Value Note Author(s) References Examples

Description

maxChar returns the number of printed characters for the widest element of x. prev calculates the previous element for each element in x. nxt calculates the next element for each element in x. runhead determines whether each element is the ‘head’ (start) of a run.

Usage

1
2
3
4
maxChar(x)
prev(x)
nxt(x)
runhead(x)

Arguments

x

vector

Details

If you forget to round or signif a numeric column, you may get more digits than desired in your output file; maxChar can warn you. See examples.

prev is used by runhead. Note that there is no element previous to the first element in a vector, so prev returns NA in that position. nxt is the reverse of prev (literally). Note that next is a reserved language word in R.

If a ‘run’ is a sequence (possibly of length one) of identical successive values in a vector, runhead determines whether an element is the first in such a sequence. Note that by definition, the first element is the start of a run; thus runhead returns TRUE in that position, even though prev returns NA.

Value

maxChar: a scalar integer prev: a vector of the same class nxt: a vector of the same class runhead: a vector of logicals

Note

NAs in the argument to runhead give surprising but reasonable results. It cannot be known whether they are the heads of runs, nor can it be known whether values immediately following them are heads of runs. To treat NAs deterministically, convert to some definite value first.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

Examples

1
2
3
4
5
6
maxChar(c(1.2,1.234))
prev(c(1,2,NA,3,3,NA,4))
nxt(c(1,2,NA,3,3,NA,4))
runhead(c(1,2,NA,3,3,NA,4))
runhead(logical(0))
runhead(factor(c('a',NA,'a','a','b','b')))

metrumrg documentation built on May 2, 2019, 5:55 p.m.