~showard314/ubuntu/karmic/r-base/remove_start_comments

« back to all changes in this revision

Viewing changes to src/library/base/man/abbreviate.Rd

  • Committer: Bazaar Package Importer
  • Author(s): Dirk Eddelbuettel
  • Date: 2009-01-19 12:40:24 UTC
  • mfrom: (5.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090119124024-abxsf4e0y7713w9m
Tags: 2.8.1-2
debian/control: Add another Build-Depends: exclusion for the 
'kfreebsd-i386 kfreebsd-amd64 hurd-i386' architecture to openjdk-6-jdk.
Thanks to Petr Salinger for the heads-up.               (Closes: 512324)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
% File src/library/base/man/abbreviate.Rd
2
2
% Part of the R package, http://www.R-project.org
3
3
% Copyright 1995-2007 R Core Development Team
 
4
% Copyright 2008      The R Foundation
4
5
% Distributed under GPL 2 or later
5
6
 
6
7
\name{abbreviate}
7
8
\title{Abbreviate Strings}
8
9
\usage{
9
10
abbreviate(names.arg, minlength = 4, use.classes = TRUE,
10
 
           dot = FALSE, method = c("left.kept", "both.sides"))
 
11
           dot = FALSE, strict = FALSE, method = c("left.kept", "both.sides"))
11
12
}
12
13
\alias{abbreviate}
13
14
\arguments{
16
17
  \item{minlength}{the minimum length of the abbreviations.}
17
18
  \item{use.classes}{logical (currently ignored by \R).}
18
19
  \item{dot}{logical: should a dot (\code{"."}) be appended?}
 
20
  \item{strict}{logical: should \code{minlength} be observed strictly?
 
21
    Note that setting \code{strict=TRUE} may return \emph{non}-unique
 
22
    strings.}
19
23
  \item{method}{a string specifying the method used with default
20
24
    \code{"left.kept"}, see \sQuote{Details} below.}
21
25
}
22
26
\description{
23
27
  Abbreviate strings to at least \code{minlength} characters,
24
 
  such that they remain \emph{unique} (if they were).
 
28
  such that they remain \emph{unique} (if they were),
 
29
  unless \code{strict=TRUE}.
25
30
}
26
31
\details{
27
32
  The algorithm (\code{method = "left.kept"}) used is similar to that of
42
47
 
43
48
  If \code{use.classes} is \code{FALSE} then the only distinction is to
44
49
  be between letters and space.  This has NOT been implemented.
45
 
  
46
 
  Elements of \code{names.arg} with embedded nul bytes will be truncated
47
 
  at the first nul.
48
50
}
49
51
\value{
50
52
  A character vector containing abbreviations for the strings in its
53
55
  the same \code{minlength} abbreviations then, if \code{method =
54
56
  "both.sides"} the basic internal \code{abbreviate()} algorithm is
55
57
  applied to the characterwise \emph{reversed} strings; if there are
56
 
  still duplicated abbreviations, \code{minlength} is
57
 
  incremented by one and new abbreviations are found for those elements
58
 
  only.  This process is repeated until all unique elements of
59
 
  \code{names.arg} have unique abbreviations.
 
58
  still duplicated abbreviations and if \code{strict=FALSE} as by
 
59
  default, \code{minlength} is incremented by one and new abbreviations
 
60
  are found for those elements only.  This process is repeated until all
 
61
  unique elements of \code{names.arg} have unique abbreviations.
60
62
 
61
63
  The character version of \code{names.arg} is attached to the returned
62
64
  value as a names argument: no other attributes are retained.
72
74
\examples{
73
75
x <- c("abcd", "efgh", "abce")
74
76
abbreviate(x, 2)
 
77
abbreviate(x, 2, strict=TRUE)# >> 1st and 3rd are == "ab"
75
78
 
76
79
(st.abb <- abbreviate(state.name, 2))
77
 
table(nchar(st.abb))# out of 50, 3 need 4 letters
78
 
 
 
80
table(nchar(st.abb))# out of 50, 3 need 4 letters :
 
81
as <- abbreviate(state.name, 3, strict=TRUE)
 
82
as[which(as == "Mss")]
 
83
\dontshow{stopifnot(which(as == "Mss") == c(21,24,25))
 
84
}
79
85
## method="both.sides" helps:  no 4-letters, and only 4 3-letters:
80
86
st.ab2 <- abbreviate(state.name, 2, method="both")
81
87
table(nchar(st.ab2))