reverse-methods: reverse

Description Usage Arguments Details Value See Also Examples

Description

A generic function for reversing vector-like or list-like objects. This man page describes methods for reversing a character vector, a Views object, or a MaskCollection object. Note that reverse is similar to but not the same as rev.

Usage

1

Arguments

x

A vector-like or list-like object.

...

Additional arguments to be passed to or from methods.

Details

On a character vector or a Views object, reverse reverses each element individually, without modifying the top-level order of the elements. More precisely, each individual string of a character vector is reversed.

Value

An object of the same class and length as the original object.

See Also

reverse-methods, Views-class, MaskCollection-class, endoapply, rev

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## On a character vector:
reverse(c("Hi!", "How are you?"))
rev(c("Hi!", "How are you?"))

## On a Views object:
v <- successiveViews(Rle(c(-0.5, 12.3, 4.88), 4:2), 1:4)
v
reverse(v)
rev(v)

## On a MaskCollection object:
mask1 <- Mask(mask.width=29, start=c(11, 25, 28), width=c(5, 2, 2))
mask2 <- Mask(mask.width=29, start=c(3, 10, 27), width=c(5, 8, 1))
mask3 <- Mask(mask.width=29, start=c(7, 12), width=c(2, 4))
mymasks <- append(append(mask1, mask2), mask3)
reverse(mymasks)

Example output

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, sd, var, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, basename, cbind, colMeans, colSums, colnames,
    dirname, 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,
    rowMeans, rowSums, rownames, sapply, setdiff, sort, table, tapply,
    union, unique, unsplit, which, which.max, which.min

Loading required package: S4Vectors
Loading required package: stats4

Attaching package: 'S4Vectors'

The following object is masked from 'package:base':

    expand.grid

[1] "!iH"          "?uoy era woH"
[1] "How are you?" "Hi!"         
Views on a 9-length Rle subject

views:
    start end width
[1]     1   1     1 [-0.5]
[2]     2   3     2 [-0.5 -0.5]
[3]     4   6     3 [-0.5 12.3 12.3]
[4]     7  10     4 [12.30  4.88  4.88 ...]
Views on a 9-length Rle subject

views:
    start end width
[1]     9   9     1 [-0.5]
[2]     7   8     2 [-0.5 -0.5]
[3]     4   6     3 [12.3 12.3 -0.5]
[4]     0   3     4 [ 4.88  4.88 12.30 ...]
Views on a 9-length Rle subject

views:
    start end width
[1]     7  10     4 [12.30  4.88  4.88 ...]
[2]     4   6     3 [-0.5 12.3 12.3]
[3]     2   3     2 [-0.5 -0.5]
[4]     1   1     1 [-0.5]
MaskCollection of length 3 and width 29
masks:
  maskedwidth maskedratio active
1           9   0.3103448   TRUE
2          14   0.4827586   TRUE
3           6   0.2068966   TRUE
all masks together:
  maskedwidth maskedratio
           19   0.6551724

IRanges documentation built on Dec. 14, 2020, 2 a.m.