From msa@biostat.mgh.harvard.edu  Thu May 27 17:40:04 1999
From: msa@biostat.mgh.harvard.edu (msa@biostat.mgh.harvard.edu)
Date: Thu, 27 May 1999 18:40:04 +0200 (MET DST)
Subject: Factor structures not preserved after dump/dput (PR#200)
Message-ID: <199905271640.SAA11822@pubhealth.ku.dk>

Full_Name: Marek Ancukiewicz
Version: 0.64.0
OS: Linux (RedHat 6.0)
Submission from: (NULL) (132.183.12.87)


I've noticed that factor structures get recoded when the data is dumped
using either dump or dput and then restored with source or dget. This
occurs when the values taken by factors do not include 1. For example:

  a <- factor(1:5,1:5,c('a','b','c','d','e'))
  b <- a[3:5]
  dput(b,'b.data')
  new.b <- dget('b.data')

Then b is not the same as new.b:
  > b
  [1] c d e
  Levels:  a b c d e 
  > new.b
  [1] a b c
  Levels:  a b c d e 

This seems to be a very serious bug. It can make one to 
mislabel treatments: a very emabarassing (and potentially 
disastrous) mistake. The reason for this bug seems to
lie in a way in which structure() treats factor structures.

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


Factor structures not preserved after dump/dput (PR#200)
msa@biostat.mgh.harvard.edu