Message-ID: <4A0A98F4.3000309@idi.ntnu.no>
Date: 2009-05-13T09:55:00Z
From: Wacek Kusnierczyk
Subject: where does the null come from?
In-Reply-To: <4A0A96D9.8070305@biostat.ku.dk>
Peter Dalgaard wrote:
> Wacek Kusnierczyk wrote:
>
>> m = matrix(1:4, 2)
>>
>> apply(m, 1, cat, '\n')
>> # 1 2
>> # 3 4
>> # NULL
>>
>> why the null?
>>
>
> It comes from unlist()ing a list of NULLs, which in turn are the return
> values of cat().
>
yes; i'd think i'd get a list of nulls, but...
> It is arguably a design-buglet not to return list(NULL, NULL), but the
> internal logic is to unlist() unless the first element is.recursive (and
> NULL is not) or the return values have different length() (and all are
> zero). It _is_, however, in accordance with the documentation (see the
> Value: section):
>
... i agree the actual outcome is appropriately explained in the docs.
i don't think it has no merit, but it's a bit surprising at first.
thanks,
vQ