Skip to content
Prev 25004 / 63424 Next

changing the mode of a factor (PR#9675)

This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--27464147-942662499-1179141762=:28940
Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-1; FORMAT=flowed
Content-Transfer-Encoding: 8BIT
Content-ID: <Pine.LNX.4.64.0705141227241.28940 at gannet.stats.ox.ac.uk>

How about the following NEWS item (a bug fix)

     o	Assigning class "factor" to an object now requires it has
 	integer (and not say double) codes.

?  (Changing the mode to double amounted to creating a new double vector 
and then assigning the attributes of the old object including the class.
We gave a more specific error message in this case in an attempt to be 
helpful ....)
'factor' returns an object of class '"factor"' which has a set of
      integer codes the length of 'x' with a '"levels"' attribute of
      mode 'character'.  If 'ordered' is true (or 'ordered' is used) the
      result has class 'c("ordered", "factor")'.

So a factor necessarily has integer codes.  That you were able to change 
the mode in earlier versions of R was a bug that has been fixed.

You may well want one of the answers to FAQ 7.10.


Please take note of the 'BUGS' section in the FAQ and the posting guide: 
three incorrect bug items in one day is unhelpful.
On Fri, 11 May 2007, frederic.gosselin at cemagref.fr wrote: