Re: [Rd] corrupt data frame: columns will be truncated or padded with NAs in: format.data.frame(x, digits = digits)

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Mon 14 Feb 2005 - 22:38:22 EST

On Mon, 14 Feb 2005, Gregor GORJANC wrote:

> Prof Brian Ripley wrote:

>> You did create a corrupt data frame by using *replacement* on part of
>> something that did not exist. The simple workaround is not to do that. One
>> can argue about what should happen in such a case and currently R assumes
>> that you know what you are doing and will only treat the data frame as a
>> list. We could make this an error, but that would add an overhead to be
>> paid by careful users too.

> I agree to some extent, however I was very surprised of this behaviour. I 
> often deal with data that have missing values and now I really do not know 
> how to manage such data. How can one add a column to existing data frame
> in such a way, that you don't get corrupted data frames as in my example?

You add a column, not replace part of a non-existent column. Isn't that obvious, given what you wrote?

There is a lot of basic documentation on data manipulation in R/S, and a whole chapter in MASS4. Somehow most other people don't seem to find this a problem.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Mon Feb 14 21:59:06 2005

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 09:02:52 EST