[R] why Vectorize conjures a list, not a vector?

Zhang Weiwu zhangweiwu at realss.com
Thu Aug 15 08:59:14 CEST 2013



On Wed, 14 Aug 2013, Hervé Pagès wrote:

> Hi Zhang,
>
> First note that a list is a vector (try is.vector(list())).
> The documentation for sapply() and Vectorize() should say *atomic*
> vector instead of vector in the desccription of the 'simplify' and
> 'SIMPLIFY' arguments.
>
> So in order for sapply() to be able to simplify the result, all runs
> of the function not only need to produce an atomic vector of the same
> type, but also of the same length. If this common length is 1, then the
> final result can be simplified to an atomic vector of the same length
> as the input.

Thanks. Thanks to Jeff Newmiller as well, you answered clearly and the 
answer solves the problem.


More information about the R-help mailing list