[Rd] corrupt data frame: columns will be truncated or padded
with NAs in: format.data.frame(x, digits = digits)
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon Feb 14 12:38:22 CET 2005
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 at 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
More information about the R-devel
mailing list