[R] why is 0 not an integer?
jim holtman
jholtman at gmail.com
Wed Aug 5 22:37:35 CEST 2009
try
> x <- 0
> class(x)
[1] "numeric"
> x <- 0L
> class(x)
[1] "integer"
>
You have to explicitly indicate that you want integer.
On Wed, Aug 5, 2009 at 4:16 PM, Steve Jaffe<sjaffe at riskspan.com> wrote:
>
> Why when I assign 0 to an element of an integer vector does the type change
> to numeric?
> Here is a particularly perplexing example:
>> v <- 0:10
>> v
> [1] 0 1 2 3 4 5 6 7 8 9 10
>> class(v)
> [1] "integer"
>> v[1] <- 0
>> class(v)
> [1] "numeric" #!!
>>
>
> --
> View this message in context: http://www.nabble.com/why-is-0-not-an-integer--tp24835423p24835423.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?
More information about the R-help
mailing list