The R Project SVN R

Rev

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

Rev 27625 Rev 30825
Line 1... Line 1...
1
\name{numeric}
1
\name{numeric}
2
\title{Numeric Vectors}
2
\title{Numeric Vectors}
3
\alias{numeric}
3
\alias{numeric}
4
\alias{as.numeric}
4
\alias{as.numeric}
5
\alias{is.numeric}
5
\alias{is.numeric}
-
 
6
\alias{is.numeric.factor}
-
 
7
\description{
-
 
8
  Creates or tests for objects of type \code{"numeric"}.
-
 
9
}
6
\usage{
10
\usage{
7
numeric(length = 0)
11
numeric(length = 0)
8
as.numeric(x, \dots)
12
as.numeric(x, \dots)
9
is.numeric(x)
13
is.numeric(x)
10
}
14
}
11
\arguments{
15
\arguments{
12
  \item{length}{desired length.}
16
  \item{length}{desired length.}
13
  \item{x}{object to be coerced or tested.}
17
  \item{x}{object to be coerced or tested.}
14
  \item{\dots}{further arguments passed to or from other methods.}
18
  \item{\dots}{further arguments passed to or from other methods.}
15
}
19
}
16
\description{
20
\details{
-
 
21
  \code{as.numeric} is a generic function, but methods must be
-
 
22
  written for \code{\link{as.double}}, which it calls.
-
 
23
 
-
 
24
  \code{is.numeric} is generic: you can write methods to handle
-
 
25
  specific classes of objects, see \link{InternalMethods}.
-
 
26
 
-
 
27
  Note that factors are false for \code{is.numeric} since there is a
-
 
28
  \code{"factor"} method.
-
 
29
}
-
 
30
\value{
17
  \code{numeric} creates a real vector of the specified length.  The
31
  \code{numeric} creates a real vector of the specified length.  The
18
  elements of the vector are all equal to \code{0}.
32
  elements of the vector are all equal to \code{0}.
19
 
33
 
20
  \code{as.numeric} attempts to coerce its argument to numeric type
34
  \code{as.numeric} attempts to coerce its argument to numeric type
21
  (either integer or real).
35
  (either integer or real).
-
 
36
  \code{as.numeric} for factors yields the codes underlying the factor
-
 
37
    levels, not the numeric representation of the labels.
22
 
38
 
23
  \code{is.numeric} returns \code{TRUE} if its argument is of type real
39
  \code{is.numeric} returns \code{TRUE} if its argument is of type numeric
24
  or type integer and \code{FALSE} otherwise.
40
  or type integer and \code{FALSE} otherwise.
25
}
41
}
26
\details{
-
 
27
  \code{is.numeric} is  generic: you can write methods to handle
-
 
28
  specific classes of objects, see \link{InternalMethods}.
-
 
29
 
-
 
30
  Note that factors are false for \code{is.numeric} but true for
-
 
31
  \code{\link{is.integer}}.
-
 
32
}
-
 
33
 
42
 
34
\note{
43
\note{
35
  \emph{\R has no single precision data type.  All real numbers are
44
  \emph{\R has no single precision data type.  All real numbers are
36
    stored in double precision format}. While \code{as.numeric} is a
45
    stored in double precision format}.
37
  generic function, user methods must be written for \code{as.double},
-
 
38
  which it calls
-
 
39
 
-
 
40
  \code{as.numeric} for factors yields the codes underlying the factor
-
 
41
    levels, not the numeric representation of the labels.
-
 
42
}
46
}
43
\references{
47
\references{
44
  Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
48
  Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
45
  \emph{The New S Language}.
49
  \emph{The New S Language}.
46
  Wadsworth \& Brooks/Cole.
50
  Wadsworth \& Brooks/Cole.