[R] Why a list of NULL's are reduced to NULL?

hadley wickham h.wickham at gmail.com
Fri Dec 11 19:05:58 CET 2009


> A very common situation is that the users don't know all the possible
> return types of 'some_third_party_function()'. If the users don't know
> all the return types, he/she can not make sure the return type of
> function(x) {...} be always the same. How do you deal with this case?

It's not that common.  It's pretty bad practice to return different
types from a function depending on the input parameters.  In many
languages this isn't even possible.

The solution is to write a function that takes the output from the
first function, inspects it, and coerces all possibilities to the same
type.

Hadley

-- 
http://had.co.nz/




More information about the R-help mailing list