Description Group Generics Summary Logical Data Methods Numerical Data Methods Character Data Methods Factor Data Methods Author(s) See Also Examples
Common operations on Rle objects.
Rle objects have support for S4 group generic functionality:
Arith
"+"
, "-"
, "*"
, "^"
,
"%%"
, "%/%"
, "/"
Compare
"=="
, ">"
, "<"
, "!="
,
"<="
, ">="
Logic
"&"
, "|"
Ops
"Arith"
, "Compare"
, "Logic"
Math
"abs"
, "sign"
, "sqrt"
,
"ceiling"
, "floor"
, "trunc"
, "cummax"
,
"cummin"
, "cumprod"
, "cumsum"
, "log"
,
"log10"
, "log2"
, "log1p"
, "acos"
,
"acosh"
, "asin"
, "asinh"
, "atan"
,
"atanh"
, "exp"
, "expm1"
, "cos"
,
"cosh"
, "sin"
, "sinh"
, "tan"
, "tanh"
,
"gamma"
, "lgamma"
, "digamma"
, "trigamma"
Math2
"round"
, "signif"
Summary
"max"
, "min"
, "range"
,
"prod"
, "sum"
, "any"
, "all"
Complex
"Arg"
, "Conj"
, "Im"
,
"Mod"
, "Re"
See S4groupGeneric for more details.
In the code snippets below, x
is an Rle object:
summary(object, ..., digits = max(3, getOption("digits") - 3))
:
Summarizes the Rle object using an atomic vector convention. The
digits
argument is used for number formatting with
signif()
.
In the code snippets below, x
is an Rle object:
!x
:
Returns logical negation (NOT) of x
.
which(x)
:
Returns an integer vector representing the TRUE
indices of
x
.
In the code snippets below, x
is an Rle object:
diff(x, lag = 1, differences = 1
:
Returns suitably lagged and iterated differences of x
.
lag
An integer indicating which lag to use.
differences
An integer indicating the order of the difference.
pmax(..., na.rm = FALSE)
, pmax.int(..., na.rm = FALSE)
:
Parallel maxima of the Rle input values. Removes NA
s when
na.rm = TRUE
.
pmin(..., na.rm = FALSE)
, pmin.int(..., na.rm = FALSE)
:
Parallel minima of the Rle input values. Removes NA
s when
na.rm = TRUE
.
which.max(x)
: Returns the index of the first element matching
the maximum value of x
.
mean(x, na.rm = FALSE)
:
Calculates the mean of x
. Removes NA
s when
na.rm = TRUE
.
var(x, y = NULL, na.rm = FALSE)
:
Calculates the variance of x
or covariance of x
and y
if both are supplied. Removes NA
s when na.rm = TRUE
.
cov(x, y, use = "everything")
, cor(x, y, use = "everything")
:
Calculates the covariance and correlation respectively of Rle objects
x
and y
.
The use
argument is an optional character string giving a method for
computing covariances in the presence of missing values. This must be
(an abbreviation of) one of the strings "everything"
,
"all.obs"
, "complete.obs"
, "na.or.complete"
, or
"pairwise.complete.obs"
.
sd(x, na.rm = FALSE)
:
Calculates the standard deviation of x
. Removes NA
s
when na.rm = TRUE
.
median(x, na.rm = FALSE)
:
Calculates the median of x
. Removes NA
s when
na.rm = TRUE
.
quantile(x, probs = seq(0, 1, 0.25), na.rm = FALSE, names = TRUE, type = 7, ...)
:
Calculates the specified quantiles of x
.
probs
A numeric vector of probabilities with values in [0,1].
na.rm
If TRUE
, removes NA
s from x
before the quantiles are computed.
names
If TRUE
, the result has names describing the
quantiles.
type
An integer between 1 and 9 selecting one of the nine
quantile algorithms detailed in quantile
.
Further arguments passed to or from other methods.
mad(x, center = median(x), constant = 1.4826, na.rm = FALSE, low = FALSE, high = FALSE)
:
Calculates the median absolute deviation of x
.
center
The center to calculate the deviation from.
constant
The scale factor.
na.rm
If TRUE
, removes NA
s from x
before the mad is computed.
low
If TRUE
, compute the 'lo-median'.
high
If TRUE
, compute the 'hi-median'.
IQR(x, na.rm = FALSE)
:
Calculates the interquartile range of x
.
na.rm
If TRUE
, removes NA
s from x
before the IQR is computed.
smoothEnds(y, k = 3)
:
Smooth end points of an Rle y
using subsequently smaller
medians and Tukey's end point rule at the very end.
k
An integer indicating the width of largest median window; must be odd.
In the code snippets below, x
is an Rle object:
nchar(x, type = "chars", allowNA = FALSE)
:
Returns an integer Rle representing the number of characters in the
corresponding values of x
.
type
One of c("bytes", "chars", "width")
.
allowNA
Should NA
be returned for invalid multibyte
strings rather than throwing an error?
substr(x, start, stop)
, substring(text, first, last = 1000000L)
:
Returns a character or factor Rle containing the specified substrings
beginning at start
/first
and ending at
stop
/last
.
chartr(old, new, x)
:
Returns a character or factor Rle containing a translated version of
x
.
old
A character string specifying the characters to be translated.
new
A character string specifying the translations.
tolower(x)
:
Returns a character or factor Rle containing a lower case version of
x
.
toupper(x)
:
Returns a character or factor Rle containing an upper case version of
x
.
sub(pattern, replacement, x, ignore.case = FALSE,
perl = FALSE, fixed = FALSE, useBytes = FALSE)
:
Returns a character or factor Rle containing replacements based on
matches determined by regular expression matching. See sub
for a description of the arguments.
gsub(pattern, replacement, x, ignore.case = FALSE,
perl = FALSE, fixed = FALSE, useBytes = FALSE)
:
Returns a character or factor Rle containing replacements based on
matches determined by regular expression matching. See gsub
for a description of the arguments.
paste(..., sep = " ", collapse = NULL)
:
Returns a character or factor Rle containing a concatenation of
the values in ...
.
In the code snippets below, x
is an Rle object:
levels(x)
, levels(x) <- value
:
Gets and sets the factor levels, respectively.
nlevels(x)
:
Returns the number of factor levels.
droplevels(x)
:
Drops unused factor levels.
P. Aboyoun
Rle objects
S4groupGeneric
1 2 3 4 5 6 7 8 9 10 11 12 13 |
Loading required package: stats4
Loading required package: BiocGenerics
Loading required package: parallel
Attaching package: 'BiocGenerics'
The following objects are masked from 'package:parallel':
clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
clusterExport, clusterMap, parApply, parCapply, parLapply,
parLapplyLB, parRapply, parSapply, parSapplyLB
The following objects are masked from 'package:stats':
IQR, mad, xtabs
The following objects are masked from 'package:base':
Filter, Find, Map, Position, Reduce, anyDuplicated, append,
as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
rbind, rownames, sapply, setdiff, sort, table, tapply, union,
unique, unsplit, which, which.max, which.min
Attaching package: 'S4Vectors'
The following objects are masked from 'package:base':
colMeans, colSums, expand.grid, rowMeans, rowSums
integer-Rle of length 55 with 10 runs
Lengths: 1 2 3 4 5 6 7 8 9 10
Values : 10 9 8 7 6 5 4 3 2 1
numeric-Rle of length 55 with 10 runs
Lengths: 1 2 ... 10
Values : 3.16227766016838 3 ... 1
numeric-Rle of length 55 with 10 runs
Lengths: 1 2 3 4 5 6 7 8 9 10
Values : 121 100 81 64 49 36 25 16 9 4
[1] 1 10
[1] 220
[1] 4
[1] "the" "quick" "quick" "red" "red" "red" "fox" "fox" "fox"
[10] "fox" "jumps" "jumps" "jumps" "jumps" "jumps" "over" "over" "over"
[19] "over" "over" "over" "the" "the" "the" "the" "the" "the"
[28] "the" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]"
[37] "brown" "brown" "brown" "brown" "brown" "brown" "brown" "brown" "brown"
[46] "dog" "dog" "dog" "dog" "dog" "dog" "dog" "dog" "dog"
[55] "dog"
[1] "THE" "QUICK" "QUICK" "RED" "RED" "RED" "FOX" "FOX" "FOX"
[10] "FOX" "JUMPS" "JUMPS" "JUMPS" "JUMPS" "JUMPS" "OVER" "OVER" "OVER"
[19] "OVER" "OVER" "OVER" "THE" "THE" "THE" "THE" "THE" "THE"
[28] "THE" "LAZY" "LAZY" "LAZY" "LAZY" "LAZY" "LAZY" "LAZY" "LAZY"
[37] "BROWN" "BROWN" "BROWN" "BROWN" "BROWN" "BROWN" "BROWN" "BROWN" "BROWN"
[46] "DOG" "DOG" "DOG" "DOG" "DOG" "DOG" "DOG" "DOG" "DOG"
[55] "DOG"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.