Achim Zeileis wrote: [...]
> is.vector(as.vector(...)) is not necessarily TRUE. Consider > > x <- cars[, 1, drop=FALSE] > is.vector(x) > is.vector(as.vector(x)) > identical(x, as.vector(x)) interesting. i wonder why as.vector does not give, at the very least, a warning when the result of its application is not a vector. the purpose of as.vector, one might guess, is to obtain a vector from whatever input -- or have the statement fail if such a conversion is impossible. the 'help' page for as.vector does not really explain what as.vector returns. the section 'value' talks about vector, exclusively: "Value: For 'vector', a vector of the given length and mode. Logical vector elements are initialized to 'FALSE', numeric vector elements to '0', character vector elements to '""', raw vector elements to 'nul' bytes and list elements to 'NULL'. All attributes are removed from the answer if it is of an atomic mode." fine, but what about as.vector? the section 'description' says: "'as.vector', a generic, attempts to coerce its argument into a vector of mode 'mode' (the default is to coerce to whichever mode is most convenient)." fine, but what if the attempt is unsuccessful? the following fails: as.vector(as.vector) # Error in as.vector(x, mode) : # cannot coerce type 'closure' to vector of type 'any' but as.vector(data.frame()) 'works', even though the result is not a vector of type 'any' either. perhaps the 'help' page might be made more helpful? vQ ______________________________________________ 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.