[Rd] Why can't I "unclass" an array?

Terry Therneau therneau at mayo.edu
Fri Dec 21 15:05:21 CET 2012

In a real example I was trying to remove the class from the result of table, just because 
it was to be used as a building block for other things and a simple integer vector seemed 
likely to be most efficient.
   I'm puzzled as to why unclass doesn't work.

 > zed <- table(1:5)
 > class(zed)
[1] "table"
 > class(unclass(zed))
[1] "array"
 > class(unclass(unclass(unclass(zed))))
[1] "array"

 > class(as.vector(zed))
[1] "integer"
 > sessionInfo()
R Under development (unstable) (2012-11-28 r61176)
Platform: i686-pc-linux-gnu (32-bit)

  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=C
  [7] LC_PAPER=C                 LC_NAME=C
  [9] LC_ADDRESS=C               LC_TELEPHONE=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

More information about the R-devel mailing list