The R Project SVN R

Rev

Rev 68948 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 68948 Rev 74653
Line 1... Line 1...
1
% File src/library/grDevices/man/extendrange.Rd
1
% File src/library/grDevices/man/extendrange.Rd
2
% Part of the R package, https://www.R-project.org
2
% Part of the R package, https://www.R-project.org
3
% Copyright 1995-2007 R Core Team
3
% Copyright 1995-2018 R Core Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
 
5
 
6
\name{extendrange}
6
\name{extendrange}
7
\alias{extendrange}
7
\alias{extendrange}
8
\title{Extend a Numerical Range by a Small Percentage}
8
\title{Extend a Numerical Range by a Small Percentage}
Line 15... Line 15...
15
}
15
}
16
\arguments{
16
\arguments{
17
  \item{x}{numeric vector; not used if \code{r} is specified.}
17
  \item{x}{numeric vector; not used if \code{r} is specified.}
18
  \item{r}{numeric vector of length 2; defaults to the
18
  \item{r}{numeric vector of length 2; defaults to the
19
    \code{\link{range}} of \code{x}.}
19
    \code{\link{range}} of \code{x}.}
20
  \item{f}{number specifying the fraction by which the range should be
20
  \item{f}{positive number(s) specifying the fraction by which the range should be
-
 
21
    extended.  If longer than one, \code{f[1]} is used on the left, and
21
    extended.}
22
    \code{f[2]} on the right.}
22
}
23
}
23
\seealso{\code{\link{range}}; \code{\link{pretty}} which can be
24
\seealso{\code{\link{range}}; \code{\link{pretty}} which can be
24
  considered a sophisticated extension of \code{extendrange}.
25
  considered a sophisticated extension of \code{extendrange}.
25
}
26
}
26
\value{
27
\value{
27
  A numeric vector of length 2, \code{r + c(-f,f) * diff(r)}.
28
  A numeric vector of length 2, \code{r + c(-f1,f2) * diff(r)}, where
-
 
29
  f1 is \code{f[1]} and f2 is \code{f[2]} or \code{f} if it is of length
-
 
30
  one.
28
}
31
}
29
\examples{
32
\examples{
30
x <- 1:5
33
x <- 1:5
31
(r <- range(x))         # 1    5
34
(r <- range(x))         # 1    5
32
extendrange(x)          # 0.8  5.2
35
extendrange(x)          # 0.8  5.2
33
extendrange(x, f= 0.01) # 0.96 5.04
36
extendrange(x, f= 0.01) # 0.96 5.04
-
 
37
 
-
 
38
## extend more to the right:
-
 
39
extendrange(x, f=c(.01,.03)) # 0.96 5.12
-
 
40
 
34
## Use 'r' if you have it already:
41
## Use 'r' if you have it already:
35
stopifnot(identical(extendrange(r = r),
42
stopifnot(identical(extendrange(r = r),
36
                    extendrange(x)))
43
                    extendrange(x)))
37
}
44
}
38
\keyword{dplot}
45
\keyword{dplot}