From pinard at iro.umontreal.ca  Fri Jun  9 00:58:06 2006
From: pinard at iro.umontreal.ca (=?iso-8859-1?Q?Fran=E7ois?= Pinard)
Date: Thu, 8 Jun 2006 18:58:06 -0400
Subject: [Rd] NAs in unsplit factor
In-Reply-To: <17544.38613.777136.185868@gargle.gargle.HOWL>
References: <17544.38613.777136.185868@gargle.gargle.HOWL>
Message-ID: <20060608225806.GA23457@phenix.progiciels-bpi.ca>

[Jeff Enos]

>Below is a simple example calling split and unsplit on a numeric
>vector of length 2 where 'f' is c(1,NA).

>> unsplit(split(c(1,2), c(1,NA)), c(1,NA))
>[1] 1 0

>I noticed that the call to vector in unsplit gives us 0 as the 2nd
>element of the result.

>Is this the intended result, as opposed to NA?

?unsplit says:

  'unsplit' reverses the effect of 'split'.

and later explains:

  'unsplit' returns a vector for which 'split(x, f)' equals 'value'

So some may argue that, while not necessarily intended, that this is at 
least not unintended :-).  Yet, why "0" is chosen here, among a myriad 
of possibilities?  "NA", as you suggest, might be a more neutral choice.

-- 
Fran?ois Pinard   http://pinard.progiciels-bpi.ca



[Rd] NAs in unsplit factor
=?iso-8859-1?Q?Fran=E7ois?= Pinard