[R] How to see if row names of a dataframe are stored compactly

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Oct 14 09:30:14 CEST 2006


On Fri, 13 Oct 2006, jim holtman wrote:

> Take a look with 'dput' and you will see the difference:
>
>> row.names(x) <- 1:n
>> dput(x)
> structure(list(V1 = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), V2 = c(11,
> 12, 13, 14, 15, 16, 17, 18, 19, 20)), .Names = c("V1", "V2"), row.names = c(NA,
> 10), class = "data.frame")
>> row.names(x) <- 2:(n+1)
>> dput(x)
> structure(list(V1 = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), V2 = c(11,
> 12, 13, 14, 15, 16, 17, 18, 19, 20)), .Names = c("V1", "V2"), row.names = c(2,
> 3, 4, 5, 6, 7, 8, 9, 10, 11), class = "data.frame")
>>
>
> 'row.names' is different.

Unfortunately, dput() does not give an accurate representation of these 
objects: see the warnings on its help page.  That is why I mention dump() 
not dput() in my reply.

-- 
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-help mailing list