Reputation: 623
how can i determine type of variable in R?
t <- seq(from=0, to=10, by=2)
p <- 2
t and p are both: is.numeric, is.atomic, is.vector, not is.list, typeof double, class numeric.
How to determine that p is just only a number and that t is something more?
Upvotes: 0
Views: 101
Reputation: 18620
To know the class of an object in R:
class(t)
class(p)
These 2 objects share the same class numeric
(they are actually both vectors of numerics, even p is a vector of length 1).
So to differenciate them you should use length
:
length(t)
length(p)
Upvotes: 4