pdmmac at mcmaster.ca
2007-Apr-22 03:19 UTC
[Rd] dput/dget when a data frame has 2 rows (PR#9627)
This doesn't seem right; I'm using R version 2.4.1 (2006-12-18) on Mac OS and Win XP and find the same issue:> mydataframe <- data.frame(ppi=c(.5,.5),mmu=c(5,10)) > dput(mydataframe,"mydataframe.txt") > dget("mydataframe.txt")Error in attributes(.Data) <- c(attributes(.Data), attrib) : row names must be 'character' or 'integer', not 'double'> mydataframe3 <- data.frame(ppi=c(.5,.5,.5),mmu=c(5,10,15)) > dput(mydataframe3,"mydataframe3.txt") > dget("mydataframe3.txt")ppi mmu 1 0.5 5 2 0.5 10 3 0.5 15 -- Peter D.M. Macdonald, D.Phil., P.Stat. Professor of Math & Statistics McMaster University Hamilton, Ontario, Canada L8S 4K1
ripley at stats.ox.ac.uk
2007-Apr-23 07:30 UTC
[Rd] dput/dget when a data frame has 2 rows (PR#9627)
It is right. The problem is that dput() does not give a faithful representation, as its help says. R 2.5.0 does a better job, since the defaults for dput() have been changed, enough so that your example works there. On Sun, 22 Apr 2007, pdmmac at mcmaster.ca wrote:> This doesn't seem right; I'm using R version 2.4.1 (2006-12-18) on Mac OS > and Win XP and find the same issue: > >> mydataframe <- data.frame(ppi=c(.5,.5),mmu=c(5,10)) >> dput(mydataframe,"mydataframe.txt") >> dget("mydataframe.txt") > Error in attributes(.Data) <- c(attributes(.Data), attrib) : > row names must be 'character' or 'integer', not 'double' >> mydataframe3 <- data.frame(ppi=c(.5,.5,.5),mmu=c(5,10,15)) >> dput(mydataframe3,"mydataframe3.txt") >> dget("mydataframe3.txt") > ppi mmu > 1 0.5 5 > 2 0.5 10 > 3 0.5 15 > > >-- 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