On Fri, 29 May 2009, Jason Vertrees wrote:
My question is: why does the paradigm of changing the type of a 1D
return value to an unlisted array exist? This introduces boundary
conditions where none need exist, thus making the coding harder and
confusing.
For example, consider:
> d = data.frame(a=rnorm(10), b=rnorm(10));
> typeof(d); # OK;
> typeof(d[,1]); # Unexpected;
> typeof(d[,1,drop=F]); # Oh, now I see.
It does make it harder for programmers, but it makes it easier for
non-programmers. In particular, it is convenient to be able to do d[1,1] to
extract a number from a matrix, rather than having to explicitly coerce the
result to stop it being a matrix.
At least the last two times this was discussed, there ended up being a
reasonable level of agreement that if someone's life had to be made harder the
programmers were better able to cope and that dropping dimensions was
preferable.
-thomas
Thomas Lumley Assoc. Professor, Biostatistics
tlum...@u.washington.edu University of Washington, Seattle
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel