File: word.Rd

package info (click to toggle)
r-cran-stringr 0.6.2-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 308 kB
  • sloc: makefile: 3
file content (44 lines) | stat: -rw-r--r-- 1,110 bytes parent folder | download | duplicates (2)
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
\name{word}
\alias{word}
\title{Extract words from a sentence.}
\usage{
  word(string, start = 1L, end = start, sep = fixed(" "))
}
\arguments{
  \item{string}{input character vector.}

  \item{start}{integer vector giving position of first word
  to extract.  Defaults to first word. If negative, counts
  backwards from last character.}

  \item{end}{integer vector giving position of last word to
  extract.  Defaults to first word. If negative, counts
  backwards from last character.}

  \item{sep}{separator between words.  Defaults to single
  space.}
}
\value{
  character vector of words from \code{start} to \code{end}
  (inclusive). Will be length of longest input argument.
}
\description{
  Extract words from a sentence.
}
\examples{
sentences <- c("Jane saw a cat", "Jane sat down")
word(sentences, 1)
word(sentences, 2)
word(sentences, -1)
word(sentences, 2, -1)

# Also vectorised over start and end
word(sentences[1], 1:3, -1)
word(sentences[1], 1, 1:4)

# Can define words by other separators
str <- 'abc.def..123.4568.999'
word(str, 1, sep = fixed('..'))
word(str, 2, sep = fixed('..'))
}