| scalar | R Documentation |
Coerce objects to scalars (vectors of length 1).
as.scalar(x, mode = "any")
is.scalar(x, mode = "any")
as.scalar.logical(x)
as.scalar.integer(x)
as.scalar.double(x)
as.scalar.numeric(x)
as.scalar.complex(x)
as.scalar.character(x)
as.scalar.string(x)
as.scalar.raw(x)
as.scalar.number(x, strict = TRUE)
x |
object to be coerced or tested. |
mode |
character string naming an atomic mode or |
strict |
|
as.scalar.logical coerces an object to a vector of type
“logical” of length 1.
as.scalar.integer coerces an object to a vector of type
“integer” of length 1.
as.scalar.real, as.scalar.double and as.scalar.numeric
coerces an object to a vector of type “numeric” of length 1.
as.scalar.complex coerces an object to a vector of type
“complex” of length 1.
as.scalar.number coerces an object to a vector of type
“numeric” or “complex” of length 1.
as.scalar.string and as.scalar.character coerces an object to a
vector of type “character” of length 1.
as.scalar coerces an object to a vector of length 1 of a specified mode.
A vector of length 1.
## if the type converting from and converting to are identical,
## as.scalar() is a much shorter way of writing what you intend.
as.scalar(c(TRUE, FALSE, NA))
as.scalar(1:100)
as.scalar(1:10 + 0.5)
as.scalar(exp((0+1i) * 6 * (-4:4)))
as.scalar(letters)
## if the type converting from and converting to are not identical, it
## is better to specify the type converting to.
as.scalar.logical(c(TRUE, FALSE, NA))
as.scalar.integer(c(TRUE, FALSE, NA))
as.scalar.numeric(c(TRUE, FALSE, NA))
as.scalar.complex(c(TRUE, FALSE, NA))
as.scalar.character(c(TRUE, FALSE, NA))
as.scalar(TRUE, "character")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.