Thursday, April 12, 2012

How to create a vector of integers with structure()?

I don't seem to be able to produce a vector of integers using structure().



> x <- structure(c(1,2), class='integer', mode='integer', storage.mode='integer')
> paste(class(x), mode(x), storage.mode(x), is.integer(x))
[1] "integer numeric double FALSE"


Compare with a true vector of integers:



> y <- as.integer(c(1,2))
> paste(class(y), mode(y), storage.mode(y), is.integer(y))
[1] "integer numeric integer TRUE"


Any idea?





No comments:

Post a Comment