Semantics of sequences in R
Stefan Evert wrote:
Dear vQ,
vectors (can-be-considered-lists),
can you please stop repeating this nonsense? I don't think anybody ever claimed that vectors can be considered list.
yes, it is nonsense. yes, there is one person who repeatedly made this claim. please read the archives; specifically, [1]. note this statement: "Note that any vector can be considered to be a list." [1] https://stat.ethz.ch/pipermail/r-help/2009-February/186932.html when you're talking about nonsense, please attribute it to the right person.
It's rather the other way round: lists can also be seen as vectors to R (possibly they are implemented as such, but I don't much about the internals of R).
not *all* lists are vectors; pairlists are not, though they are lists.
a <- as.list(1:10) b <- 1:10 is.vector(a)
[1] TRUE
is.list(a)
[1] TRUE
is.vector(b)
[1] TRUE
is.list(b)
[1] FALSE Hence the confusion about
mode(as.vector(a))
[1] "list"
but
mode(unlist(a))
# "numeric"
class(unlist(a))
# integer
which prompted the original comment that you are taking so much exception to.
which original comment?
as to "it could only work in very specific circumstances" -- no, it would work for any list whatsoever, provided the user has a correctly implemented comparator. for example, i'd like to sort a list of vectors by the vectors' length -- is this a very exotic idea?
Honestly, I can't think of a situation where I would want to do than in R. In a Perl script, quite likely; but this is a kind of data manipulation that R wasn't really designed for IMHO.
irrespectively of how exotic sorting lists of vectors can be in a system for the manipulation of a comprehensive range of sorts of data, having a procedure called 'sort.list' complain about being called on a list is a sure source of confusion. how much is it likely that people will want to sort complex numbers in a system where complex numbers are incomparable? best, vQ
Not that I'd mind having sort() operate properly on lists; it just isn't something I miss in the language. Best, Stefan