Section 12 R Atomic Class: Double

  • A double vector stores regular numbers

  • It can include both negative and positive, large or small, with or without decimal places

  • It is a historical anomaly that R has two names for its floating-point vectors, double and numeric (and formerly had real).

  • The potential confusion is that R has used mode numeric to mean double or integer, which conflicts with the S4 usage.

  • R class double is accurate up to 16 significant digits.

  • Function to identify the object type: class, typeof, mode

  • Other functions to check the object type as double, numeric: is.double, is.numeric

12.1 Examples

x <- 3.4
x
class(x)
typeof(x)
is.double(x)

y <- 1
y
class(y)

z <- pi
z
class(z)
is.double(z)

a <- 1.5e05
a
class(a)
is.double(a)

b <- 1.9e-5
b
class(b)
is.numeric(b)

c <- 2^5
c
class(c)
is.numeric(c)

d <- 0
d
class(d)
is.numeric(d)

m <- 1
n <- 6L
p <- m+n
q <- m*n
p; q
class(p)
class(q)