b/c
> class(0)
[1] "numeric"

> typeof(0)
[1] "double"

> class(0L)
[1] "integer"

> typeof(0L)
[1] "integer"

When you call the ":" function it always returns an integer sequence,
but when you assign a numeric to an element of the vector it gets
coerced to the more general type, in this case, numeric.

Note that "is.numeric" returns TRUE for both is.numeric(0) and
is.numeric(0L).

 

Daniel Gerlanc
Associate Analyst
Geode Capital Management
1 Post Office Sq, Floor 28
Boston, MA 02109
daniel.gerl...@geodecapital.com

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to