File: letter.Rd

package info (click to toggle)
r-bioc-biostrings 2.42.1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 14,652 kB
  • ctags: 721
  • sloc: ansic: 10,262; sh: 11; makefile: 2
file content (74 lines) | stat: -rw-r--r-- 1,589 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
\name{letter}

\alias{letter}
\alias{letter,character-method}
\alias{letter,XString-method}
\alias{letter,XStringViews-method}
\alias{letter,MaskedXString-method}


\title{Subsetting a string}

\description{
  Extract a substring from a string by picking up individual
  letters by their position.
}

\usage{
letter(x, i)
}

\arguments{
  \item{x}{
    A character vector, or an \link{XString}, \link{XStringViews}
    or \link{MaskedXString} object.
  }
  \item{i}{
    An integer vector with no NAs.
  }
}

\details{
  Unlike with the \code{substr} or \code{substring} functions,
  \code{i} must contain valid positions.
}

\value{
  A character vector of length 1 when \code{x} is an \link{XString}
  or \link{MaskedXString} object (the masks are ignored for the latter).

  A character vector of the same length as \code{x} when \code{x}
  is a character vector or an \link{XStringViews} object.

  Note that, because \code{i} must contain valid positions,
  all non-NA elements in the result are guaranteed to have exactly
  \code{length(i)} characters.
}

\seealso{
  \code{\link[XVector]{subseq}},
  \link{XString-class},
  \link{XStringViews-class},
  \link{MaskedXString-class}
}

\examples{
x <- c("abcd", "ABC")
i <- c(3, 1, 1, 2, 1)

## With a character vector:
letter(x[1], 3:1)
letter(x, 3)
letter(x, i)
#letter(x, 4)             # Error!

## With a BString object:
letter(BString(x[1]), i)  # returns a character vector
BString(x[1])[i]          # returns a BString object

## With an XStringViews object:
x2 <- as(BStringSet(x), "Views")
letter(x2, i)
}

\keyword{methods}