Commit 9f2a8cf4 authored by Radford Neal's avatar Radford Neal

updates from 2.15.1 to base/R and base/man

parent 437828f7
# File src/library/base/R/files.R
# Part of the R package, http://www.R-project.org
# Copyright (C) 2007 R Development Core Team
# Copyright (C) 2007 R Core Team
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
......@@ -25,8 +25,10 @@ backsolve <- function(r, x, k=ncol(r), upper.tri = TRUE, transpose = FALSE)
if(!x.mat) x <- as.matrix(x) # k x nb
storage.mode(x) <- "double"
k <- as.integer(k)
if(k <= 0 || nrow(x) < k) stop("invalid argument values in 'backsolve'")
nb <- ncol(x)
if(is.na(k) || k <= 0 || nrow(x) < k)
stop("invalid argument values in 'backsolve'")
nb <- as.integer(ncol(x))
if(is.na(nb)) stop("invalid value of ncol(x)")
upper.tri <- as.logical(upper.tri)
transpose <- as.logical(transpose)
job <- as.integer(upper.tri + 10L*transpose)
......
......@@ -35,6 +35,10 @@ chol.default <- function(x, pivot = FALSE, LINPACK = pivot, ...)
if(!pivot && !LINPACK)
return(.Call("La_chol", as.matrix(x), PACKAGE = "base"))
## sanity checks
n <- as.integer(n)
if(is.na(n)) stop("invalid nrow(x)")
if(!is.double(x)) storage.mode(x) <- "double"
if(pivot) { ## code could be used in the other case too
......@@ -74,7 +78,7 @@ chol.default <- function(x, pivot = FALSE, LINPACK = pivot, ...)
}
}
chol2inv <- function(x, size=NCOL(x), LINPACK=FALSE)
chol2inv <- function(x, size = NCOL(x), LINPACK = FALSE)
{
if(!is.numeric(x))
stop("non-numeric argument to 'chol2inv'")
......@@ -88,17 +92,19 @@ chol2inv <- function(x, size=NCOL(x), LINPACK=FALSE)
nr <- length(x)
nc <- 1L
}
nr <- as.integer(nr)
if(is.na(nr)) stop("invalid nrow(x)")
size <- as.integer(size)
if(size <= 0L || size > nr || size > nc)
if(is.na(size) || size <= 0L || size > nr || size > nc)
stop("invalid 'size' argument in 'chol2inv'")
if(!is.double(x)) storage.mode(x) <- "double"
z <- .Fortran("ch2inv",
x=x,
x = x,
nr,
size,
v=matrix(0, nrow=size, ncol=size),
info=integer(1L),
DUP=FALSE, PACKAGE="base")
v = matrix(0, nrow=size, ncol=size),
info = integer(1L),
DUP = FALSE, PACKAGE = "base")
if(z$info)
stop("singular matrix in 'chol2inv'")
z$v
......
......@@ -53,15 +53,14 @@ cut.default <-
codes.only <- TRUE
else if (length(labels) != nb - 1L)
stop("labels/breaks length conflict")
code <- .C("bincode",
x = as.double(x),
n = as.integer(length(x)),
breaks = as.double(breaks),
as.integer(nb),
code= integer(length(x)),
right= as.logical(right),
include= as.logical(include.lowest), naok = TRUE,
NAOK= TRUE, DUP = FALSE, PACKAGE = "base") $code
if(!is.double(x)) storage.mode(x) <- "double"
if(!is.double(breaks)) storage.mode(breaks) <- "double"
nx <- as.integer(length(x))
if (is.na(nx)) stop("invalid value of length(x)")
code <- .C("bincode", x = x, n = nx, breaks = breaks,
as.integer(nb), code = integer(nx), right = as.logical(right),
include = as.logical(include.lowest), naok = TRUE,
NAOK = TRUE, DUP = FALSE, PACKAGE = "base") $code
## NB this relies on passing NAOK in that position!
if(codes.only) code
else factor(code, seq_along(labels), labels, ordered = ordered_result)
......
......@@ -24,7 +24,7 @@ diff.default <- function(x, lag = 1L, differences = 1L, ...)
lag < 1L || differences < 1L)
stop("'lag' and 'differences' must be integers >= 1")
if (lag * differences >= xlen)
return(x[0]) # empty of proper mode
return(x[0L]) # empty, but of proper mode
r <- unclass(x) # don't want class-specific subset methods
i1 <- -seq_len(lag)
if (ismat)
......
......@@ -39,6 +39,8 @@ eigen <- function(x, symmetric, only.values = FALSE, EISPACK = FALSE)
n <- nrow(x)
if (!n) stop("0 x 0 matrix")
if (n != ncol(x)) stop("non-square matrix in 'eigen'")
n <- as.integer(n)
if(is.na(n)) stop("invalid nrow(x)")
complex.x <- is.complex(x)
if(!complex.x && !is.double(x))
......@@ -68,17 +70,15 @@ eigen <- function(x, symmetric, only.values = FALSE, EISPACK = FALSE)
dbl.n <- double(n)
if(symmetric) {##--> real values
if(complex.x) {
xr <- Re(x)
xi <- Im(x)
z <- .Fortran("ch",
n,
n,
xr,
xi,
Re(x),
Im(x),
values = dbl.n,
!only.values,
vectors = xr,
ivectors = xi,
vectors = Re(x),
ivectors = Im(x),
dbl.n,
dbl.n,
double(2*n),
......@@ -166,5 +166,5 @@ eigen <- function(x, symmetric, only.values = FALSE, EISPACK = FALSE)
ord <- sort.list(Mod(z$values), decreasing = TRUE)
}
list(values = z$values[ord],
vectors = if(!only.values) z$vectors[,ord, drop = FALSE])
vectors = if(!only.values) z$vectors[, ord, drop = FALSE])
}
......@@ -520,19 +520,19 @@ loadNamespace <- function (package, lib.loc = NULL,
for (p in nsInfo$exportPatterns)
exports <- c(ls(env, pattern = p, all.names = TRUE), exports)
## certain things should never be exported.
if (length(exports)) {
stoplist <- c(".__NAMESPACE__.", ".__S3MethodsTable__.",
".packageName", ".First.lib", ".onLoad",
".onAttach", ".conflicts.OK", ".noGenerics")
exports <- exports[! exports %in% stoplist]
}
##
if(.isMethodsDispatchOn() && methods:::.hasS4MetaData(ns) &&
!identical(package, "methods") ) {
## cache generics, classes in this namespace (but not methods itself,
## which pre-cached at install time
methods:::cacheMetaData(ns, TRUE, ns)
## load actions may have added objects matching patterns
for (p in nsInfo$exportPatterns) {
expp <- ls(ns, pattern = p, all.names = TRUE)
newEx <- !(expp %in% exports)
if(any(newEx))
exports <- c(expp[newEx], exports)
}
## process class definition objects
expClasses <- nsInfo$exportClasses
##we take any pattern, but check to see if the matches are classes
......@@ -585,7 +585,8 @@ loadNamespace <- function (package, lib.loc = NULL,
## skip primitives
addGenerics <- addGenerics[sapply(addGenerics, function(what) ! is.primitive(get(what, mode = "function", envir = ns)))]
## the rest must be generic functions, implicit or local
ok <- sapply(addGenerics, function(what) methods::is(get(what, mode = "function", envir = ns), "genericFunction"))
## or have been cached via a DEPENDS package
ok <- sapply(addGenerics, methods:::.findsGeneric, ns)
if(!all(ok)) {
bad <- sort(unique(addGenerics[!ok]))
msg <-
......@@ -596,6 +597,8 @@ loadNamespace <- function (package, lib.loc = NULL,
paste(sQuote(bad), collapse = ", ")),
domain = NA, call. = FALSE)
}
else if(any(ok > 1L)) #from the cache, don't add
addGenerics <- addGenerics[ok < 2L]
}
### <note> Uncomment following to report any local generic functions
### that should have been exported explicitly. But would be reported
......@@ -670,6 +673,13 @@ loadNamespace <- function (package, lib.loc = NULL,
domain = NA)
exports <- c(exports, expClasses, expTables)
}
## certain things should never be exported.
if (length(exports)) {
stoplist <- c(".__NAMESPACE__.", ".__S3MethodsTable__.",
".packageName", ".First.lib", ".onLoad",
".onAttach", ".conflicts.OK", ".noGenerics")
exports <- exports[! exports %in% stoplist]
}
namespaceExport(ns, exports)
sealNamespace(ns)
runUserHook(package, pkgpath)
......
......@@ -37,8 +37,10 @@ qr.default <- function(x, tol = 1e-07, LAPACK = FALSE, ...)
return(res)
}
p <- ncol(x) # guaranteed to be integer
n <- nrow(x)
p <- as.integer(ncol(x))
if(is.na(p)) stop("invalid ncol(x)")
n <- as.integer(nrow(x))
if(is.na(n)) stop("invalid nrow(x)")
res <- .Fortran("dqrdc2",
qr=x,
n,
......@@ -63,12 +65,15 @@ qr.coef <- function(qr, y)
{
if( !is.qr(qr) )
stop("first argument must be a QR decomposition")
n <- nrow(qr$qr)
p <- ncol(qr$qr)
n <- as.integer(nrow(qr$qr))
if(is.na(n)) stop("invalid nrow(qr$qr)")
p <- as.integer(ncol(qr$qr))
if(is.na(p)) stop("invalid ncol(qr$qr)")
k <- as.integer(qr$rank)
im <- is.matrix(y)
if (!im) y <- as.matrix(y)
ny <- ncol(y)
ny <- as.integer(ncol(y))
if(is.na(ny)) stop("invalid ncol(y)")
if (p == 0L) return( if (im) matrix(0, p, ny) else numeric() )
ix <- if ( p > n ) c(seq_len(n), rep(NA, p - n)) else seq_len(p)
if(is.complex(qr$qr)) {
......@@ -129,11 +134,12 @@ qr.qy <- function(qr, y)
a <- attr(qr, "useLAPACK")
if(!is.null(a) && is.logical(a) && a)
return(.Call("qr_qy_real", qr, as.matrix(y), 0, PACKAGE = "base"))
n <- nrow(qr$qr)
# p <- ncol(qr$qr)
n <- as.integer(nrow(qr$qr))
if(is.na(n)) stop("invalid nrow(qr$qr)")
k <- as.integer(qr$rank)
ny <- NCOL(y)
storage.mode(y) <- "double"
ny <- as.integer(NCOL(y))
if(is.na(ny)) stop("invalid NCOL(y)")
storage.mode(y) <- "double"
if(NROW(y) != n)
stop("'qr' and 'y' must have the same number of rows")
.Fortran("dqrqy",
......@@ -158,10 +164,11 @@ qr.qty <- function(qr, y)
if(!is.null(a) && is.logical(a) && a)
return(.Call("qr_qy_real", qr, as.matrix(y), 1, PACKAGE = "base"))
n <- nrow(qr$qr)
# p <- ncol(qr$qr)
n <- as.integer(nrow(qr$qr))
if(is.na(n)) stop("invalid nrow(qr$qr)")
k <- as.integer(qr$rank)
ny <- NCOL(y)
ny <- as.integer(NCOL(y))
if(is.na(ny)) stop("invalid NCOL(y)")
if(NROW(y) != n)
stop("'qr' and 'y' must have the same number of rows")
storage.mode(y) <- "double"
......@@ -184,9 +191,10 @@ qr.resid <- function(qr, y)
stop("not supported for LAPACK QR")
k <- as.integer(qr$rank)
if (k==0) return(y)
n <- nrow(qr$qr)
# p <- ncol(qr$qr)
ny <- NCOL(y)
n <- as.integer(nrow(qr$qr))
if(is.na(n)) stop("invalid nrow(qr$qr)")
ny <- as.integer(NCOL(y))
if(is.na(ny)) stop("invalid NCOL(y)")
if( NROW(y) != n )
stop("'qr' and 'y' must have the same number of rows")
storage.mode(y) <- "double"
......@@ -206,10 +214,12 @@ qr.fitted <- function(qr, y, k=qr$rank)
a <- attr(qr, "useLAPACK")
if(!is.null(a) && is.logical(a) && a)
stop("not supported for LAPACK QR")
n <- nrow(qr$qr)
n <- as.integer(nrow(qr$qr))
if(is.na(n)) stop("invalid nrow(qr$qr)")
k <- as.integer(k)
if(k > qr$rank) stop("'k' is too large")
ny <- NCOL(y)
ny <- as.integer(NCOL(y))
if(is.na(ny)) stop("invalid NCOL(y)")
if( NROW(y) != n )
stop("'qr' and 'y' must have the same number of rows")
storage.mode(y) <- "double"
......@@ -261,7 +271,8 @@ qr.X <- function (qr, complete = FALSE,
if(pivoted && ncol < length(qr$pivot))
stop("need larger value of 'ncol' as pivoting occurred")
cmplx <- mode(R) == "complex"
p <- dim(R)[2L]
p <- as.integer(dim(R)[2L])
if(is.na(p)) stop("invalid NCOL(R)")
if (ncol < p)
R <- R[, 1L:ncol, drop = FALSE]
else if (ncol > p) {
......
......@@ -18,6 +18,9 @@
svd <- function(x, nu = min(n,p), nv = min(n,p), LINPACK = FALSE)
{
x <- as.matrix(x)
if (!all(is.finite(x))) stop("infinite or missing values in 'x'")
dx <- dim(x)
n <- dx[1L]
p <- dx[2L]
......@@ -32,8 +35,7 @@ svd <- function(x, nu = min(n,p), nv = min(n,p), LINPACK = FALSE)
return (ret)
}
if (!is.double(x))
storage.mode(x) <- "double"
storage.mode(x) <- "double"
if (!LINPACK) {
res <- La.svd(x, nu, nv)
......@@ -44,7 +46,11 @@ svd <- function(x, nu = min(n,p), nv = min(n,p), LINPACK = FALSE)
return (ret)
}
if (!all(is.finite(x))) stop("infinite or missing values in 'x'")
## LINPACK only from here on.
n <- as.integer(n)
if(is.na(n)) stop("invalid nrow(x)")
p <- as.integer(p)
if(is.na(p)) stop("invalid ncol(x)")
if(nu == 0L) {
job <- 0L
......@@ -67,26 +73,25 @@ svd <- function(x, nu = min(n,p), nv = min(n,p), LINPACK = FALSE)
v <- if(job == 0L) double() else matrix(0, p, p)
mn <- min(n,p)
mm <- min(n+1L,p)
z <- .Fortran("dsvdc",
as.double(x),
x, # did storage.mode above
n,
n,
p,
d=double(mm),
d = double(mm),
double(p),
u=u,
u = u,
n,
v=v,
v = v,
p,
double(n),
as.integer(job),
info=integer(1L),
DUP=FALSE, PACKAGE="base")[c("d","u","v","info")]
info = integer(1L),
DUP = FALSE, PACKAGE = "base")[c("d","u","v","info")]
if(z$info)
stop(gettextf("error %d in 'dsvdc'", z$info), domain = NA)
z$d <- z$d[1L:mn]
z$d <- z$d[seq_len(min(n, p))]
if(nv && nv < p) z$v <- z$v[, 1L:nv, drop = FALSE]
z[c("d", if(nu) "u", if(nv) "v")]
}
......@@ -112,6 +112,8 @@ Sys.which <- function(names)
return(res)
}
for(i in names) {
## NB: this does not quote names, so user has to.
## This is documented as from R 2.15.1
ans <- suppressWarnings(system(paste(which, i), intern=TRUE,
ignore.stderr=TRUE))
## Solaris' which gives 'no foo in ...' message on stdout,
......
......@@ -7,6 +7,7 @@
\title{Marking Objects as Defunct}
\alias{Defunct}
\alias{.Defunct}
\alias{defunct}
\description{
When a function is removed from \R it should be replaced by a function
......
% File src/library/base/man/Deprecated.Rd
% Part of the R package, http://www.R-project.org
% Copyright 1995-2011 R Core Team
% Copyright 1995-2012 R Core Team
% Distributed under GPL 2 or later
\name{Deprecated}
\title{Marking Objects as Deprecated}
\alias{Deprecated}
\alias{.Deprecated}
\alias{deprecated}
\description{
When an object is about removed from \R it is first deprecated and
When an object is about to be removed from \R it is first deprecated and
should include a call to \code{.Deprecated}.
}
\usage{
......
% File src/library/base/man/EnvVar.Rd
% Part of the R package, http://www.R-project.org
% Copyright 2007-2011 R Core Team
% Copyright 2007-2012 R Core Team
% Modifications for pqR Copyright (c) 2014 Radford M. Neal.
% Distributed under GPL 2 or later
......@@ -90,7 +90,9 @@
file: see \link{Startup}. Consulted at startup.}
\item{\env{R_GSCMD}:}{Optional. The path to Ghostscript, used by
\code{\link{dev2bitmap}}, \code{\link{bitmap}} and
\code{\link{embedFonts}}. Consulted when those functions are invoked.}
\code{\link{embedFonts}}. Consulted when those functions are
invoked. Since it will be treated as if passed to
\code{\link{system}}, spaces and shell metacharacters should be escaped.}
\item{\env{R_HELPERS}:}{Optional. The number of helper threads to
use. See \code{\link{helpers}}.}
\item{\env{R_HELPERS_TRACE}:}{Optional. If set to anything, tracing
......
......@@ -74,7 +74,7 @@ pmin.int(\dots, na.rm = FALSE)
\code{NA} is \code{NA} even if it also contains an \code{NaN}.
Note that \code{max(NA, Inf) == NA} even though the maximum would be
\code{Inf} whatever the missing value actually is.
Character versions are sorted lexicographically, and this depends on
the collating sequence of the locale in use: the help for
\sQuote{\link{Comparison}} gives details. The max/min of an empty
......@@ -85,7 +85,8 @@ pmin.int(\dots, na.rm = FALSE)
}
\value{
For \code{min} or \code{max}, a length-one vector. For \code{pmin} or
\code{pmax}, a vector of length the longest of the input vectors.
\code{pmax}, a vector of length the longest of the input vectors, or
length zero if one of the inputs had zero length.
The type of the result will be that of the highest of the inputs in
the hierarchy integer < real < character.
......@@ -129,6 +130,17 @@ x <- sort(rnorm(100)); cH <- 1.35
pmin(cH, quantile(x)) # no names
pmin(quantile(x), cH) # has names
plot(x, pmin(cH, pmax(-cH, x)), type='b', main= "Huber's function")
cut01 <- function(x) pmax(pmin(x, 1), 0)
curve( x^2 - 1/4, -1.4, 1.5, col=2)
curve(cut01(x^2 - 1/4), col="blue", add=TRUE, n=500)
## pmax(), pmin() preserve attributes of *first* argument
D <- diag(x=(3:1)/4) ; n0 <- numeric()
stopifnot(identical(D, cut01(D) ),
identical(n0, cut01(n0)),
identical(n0, cut01(NULL)),
identical(n0, pmax(3:1, n0, 2)),
identical(n0, pmax(n0, 4)))
}
\keyword{univar}
\keyword{arith}
% File src/library/base/man/Memory.Rd
% Part of the R package, http://www.R-project.org
% Copyright 1995-2011 R Core Team
% Copyright 1995-2012 R Core Team
% Modifications for pqR copyright (C) 2013, 2014 Radford M. Neal
% Distributed under GPL 2 or later
......@@ -16,11 +16,11 @@
now sized automatically.
#ifdef windows
On Windows the \option{--max-mem-size} option sets the maximum memory
allocation: it has a minimum allowed value of 32M. This is intended
to catch attempts to allocate excessive amounts of memory which may
cause other processes to run out of resources. See also
\code{\link{memory.limit}}.
On Windows the \option{--max-mem-size} option (or environment variable
\env{R_MAX_MEM_SIZE}) sets the maximum memory allocation: it has a
minimum allowed value of 32M. This is intended to catch attempts to
allocate excessive amounts of memory which may cause other processes
to run out of resources. See also \code{\link{memory.limit}}.
#endif
All objects in pqR (eg, vectors, symbols, language elements, and
......
% File src/library/base/man/Sys.which.Rd
% Part of the R package, http://www.R-project.org
% Copyright 2007-10 R Core Team
% Copyright 2007-12 R Core Team
% Distributed under GPL 2 or later
\name{Sys.which}
\alias{Sys.which}
\title{Find Full Paths to Executables}
\description{
This is an interface to the system command \code{which}.
This is an interface to the system command \code{which}, or to an
emulation on Windows.
}
\usage{
Sys.which(names)
}
\arguments{
\item{names}{Character vector of names of possible executables.}
\item{names}{Character vector of names or paths of possible executables.}
}
\details{
The system command \code{which} reports on the full names of an
executable (including an executable script) found on the current path.
The system command \command{which} reports on the full path names of
an executable (including an executable script) as would be executed by
a shell, accepting either absolute paths or looking on the path.
On Windows an \sQuote{executable} is a file with extension
\file{.exe}, \file{.com}, \file{.cmd} or \file{.bat}. Such files need
......@@ -25,8 +27,11 @@ Sys.which(names)
tries.
On a Unix-alike the full path to \code{which} (usually
\file{/usr/bin/which}) is found when \R is installed and (currently)
stored in environment variable \code{WHICH}.
\file{/usr/bin/which}) is found when \R is installed.
Arguments containing spaces or other metacharacters need to be escaped
as they would be for a shell: for example Windows paths containing
spaces need to be enclosed in double quotes.
}
\value{
A character vector of the same length as \code{names}, named by
......@@ -35,10 +40,14 @@ Sys.which(names)
found. Typically the indication is \code{""}, but this does depend on
the OS (and the known exceptions are changed to \code{""}).
#ifdef windows
The paths will be short paths (8+3 components, no spaces) with
\code{\\} as the path delimiter.
#endif
On Windows the paths will be short paths (8+3 components, no spaces)
with \code{\\} as the path delimiter.
}
\note{
Except on Windows this calls the system command \command{which}: since
that is not part of e.g. the POSIX standards, exactly what it does is
OS-dependent. It will usually do tilde-expansion and it may make use
of \command{csh} aliases.
}
\examples{
## the first two are likely to exist everywhere
......
......@@ -33,6 +33,9 @@ oldClass(x) <- value
}
\details{
Here, we describe the so called \dQuote{S3} classes (and methods). For
\dQuote{S4} classes (and methods), see \sQuote{Formal classes} below.
Many \R objects have a \code{class} attribute, a character vector
giving the names of the classes from which the object \emph{inherits}.
If the object does not have a class attribute, it has an implicit
......@@ -65,10 +68,10 @@ oldClass(x) <- value
is \code{TRUE} then an integer vector of the same length as
\code{what} is returned. Each element indicates the position in the
\code{class(x)} matched by the element of \code{what}; zero indicates
no match. If \code{which} is \code{FALSE} then \code{TRUE} is
no match. If \code{which} is \code{FALSE} then \code{TRUE} is
returned by \code{inherits} if any of the names in \code{what} match
with any \code{class}.
All but \code{inherits} are \link{primitive} functions.
}
......@@ -83,14 +86,16 @@ oldClass(x) <- value
}
\section{Formal classes}{
An additional mechanism of \emph{formal} classes is available in
An additional mechanism of \emph{formal} classes, nicknamed
\dQuote{S4}, is available in
packages \pkg{methods} which is attached by default. For objects
which have a formal class, its name is returned by \code{class}
as a character vector of length one. However, S3 method selection
as a character vector of length one and method dispatch can happen on
\emph{several} arguments, instead of only the first. However, S3 method selection
attempts to treat objects from an S4 class as if they had the
appropriate S3 class attribute, as does \code{inherits}. Therefore,
S3 methods can be defined for S4 classes. See
\link{Methods} for details.
S3 methods can be defined for S4 classes. See the \sQuote{\link{Classes}}
and \sQuote{\link{Methods}} help pages for details.
The replacement version of the function sets the class to the value
provided. For classes that have a formal definition, directly
......@@ -99,8 +104,8 @@ oldClass(x) <- value
particular class.
The analogue of \code{inherits} for formal classes is
\code{\link{is}}. The two functions behave consistently
objects with one exception: S4 classes can have conditional
\code{\link{is}}. The two functions behave consistently
with one exception: S4 classes can have conditional
inheritance, with an explicit test. In this case, \code{is} will
test the condition, but \code{inherits} ignores all conditional
superclasses.
......
......@@ -57,9 +57,13 @@ as.single(x, \dots)
attributes, use \code{\link{storage.mode}}.) Character strings
containing optional whitespace followed by either a decimal
representation or a hexadecimal representation (starting with
\code{0x} or \code{0X}) can be converted. \code{as.double} for
factors yields the codes underlying the factor levels, not the numeric
representation of the labels, see also \code{\link{factor}}.
\code{0x} or \code{0X}) can be converted, as can special values such
as \code{"NA"}, \code{"NaN"}, \code{"Inf"} and \code{"infinity"},
irrespective of case.
\code{as.double} for factors yields the codes underlying the factor
levels, not the numeric representation of the labels, see also
\code{\link{factor}}.
\code{is.double} returns \code{TRUE} or \code{FALSE} depending on
whether its argument is of double \link{type} or not.
......
......@@ -75,8 +75,8 @@ d <- dir(file.path(R.home(), "bin"))
df <- dir(file.path(R.home(), "bin"), full.names = TRUE)
d[file.access(df, 0) == 0] # all exist
d[file.access(df, 1) == 0] # some are executable, some are not
d[file.access(df, 2) == 0] # hopefully all are readable
d[file.access(df, 4) == 0] # they may or may not be writable
d[file.access(df, 4) == 0] # hopefully all are readable
d[file.access(df, 2) == 0] # they may or may not be writable
#endif
}
\keyword{file}
......@@ -55,8 +55,7 @@ regexec(pattern, text, ignore.case = FALSE,
object which can be coerced by \code{as.character} to a character vector.}
\item{ignore.case}{if \code{FALSE}, the pattern matching is \emph{case
sensitive} and if \code{TRUE}, case is ignored during matching.}
\item{perl}{logical. Should perl-compatible regexps be used?
Has priority over \code{extended}.}
\item{perl}{logical. Should perl-compatible regexps be used?}
\item{value}{if \code{FALSE}, a vector containing the (\code{integer})
indices of the matches determined by \code{grep} is returned, and if
\code{TRUE}, a vector containing the matching elements themselves is
......
% File src/library/base/man/identical.Rd
% Part of the R package, http://www.R-project.org
% Copyright 2001-2010 R Core Team
% Copyright 2001-2012 R Core Team
% Copyright 2001-2010 R Core Development Team
% Distributed under GPL 2 or later
\name{identical}
......@@ -31,7 +32,7 @@ identical(x, y, num.eq = TRUE, single.NA = TRUE, attrib.as.set = TRUE,
\code{\link{slot}}s of S4 objects. It may well be too strict to set
\code{attrib.as.set = FALSE}.}
\item{ignore.bytecode}{logical indicating if byte code should be
ignored when comparing functions.}
ignored when comparing \link{closure}s.}
}
\details{
A call to \code{identical} is the way to test exact equality in
......
......@@ -23,7 +23,13 @@ is.unsorted(x, na.rm = FALSE, strictly = FALSE)
A length-one logical value. All objects of length 0 or 1 are sorted:
the result will be \code{NA} for objects of length 2 or more except for
atomic vectors and objects with a class (where the \code{>=} or \code{>}
method is used).
method is used to compare \code{x[i]} with \code{x[i-1]} for
\code{i} in \code{2:length(x)}).
}
\note{
This function is designed for objects with one-dimensional indices, as
described above. Dataframes, matrices and other arrays may give
surprising results.
}
\seealso{\code{\link{sort}}, \code{\link{order}}.}
......
% File src/library/base/man/length.Rd
% Part of the R package, http://www.R-project.org
% Copyright 1995-2011 R Core Team
% Copyright 1995-2012 R Core Team
% Distributed under GPL 2 or later
\name{length}
......@@ -24,8 +24,6 @@ length(x) <- value
The default method currently returns an \code{\link{integer}} of
length 1. Since this may change in the future and may
differ for other methods, programmers should not rely on it.
(Should the length exceed the maximum representable integer, it is
returned as \code{NA}.)
For vectors (including lists) and factors the length is the number of
elements. For an environment it is the number of objects in the
......@@ -35,8 +33,9 @@ length(x) <- value
length one: note that for functions this differs from S.
The replacement form removes all the attributes of \code{x} except its
names.
names.
}
\details{
Both functions are generic: you can write methods to handle specific
classes of objects, see \link{InternalMethods}. \code{length<-} has a
......@@ -49,6 +48,14 @@ length(x) <- value
Both are \link{primitive} functions.
}
\section{Warning}{
Package authors have written methods that return a result of
length other than one (\pkg{Formula}) and that return a vector type
\code{\link{double}} (\pkg{Matrix}), even with non-integer values