From dj at research.bell-labs.com  Sat Nov 29 20:44:30 2003
From: dj at research.bell-labs.com (David James)
Date: Sat Nov 29 20:43:39 2003
Subject: [Rd] wish list: default row.names in data.frame()
Message-ID: <20031129144430.A9462@jessie.research.bell-labs.com>

Hi,

Consider the row.names of

   a <- data.frame(x = runif(150000))
   > row.names(a)[99998:100002]
   [1] "99998"  "99999"  "1e+05"  "100001" "100002"

not wrong, but there's room for improvement.  If we replace the
expression 

   if (length(row.names) == 0)
        row.names <- seq(length = nr)

which creates a non-integer object row.names by

   if (length(row.names) == 0)
        row.names <- if(nr>0) 1:nr else integer(0) 

(or something to that effect) to create an integer row.names
that when coerced to character will produce

   b <- data.frame(x = runif(150000))
   > row.names(b)[99998:100002]
   [1] "99998"  "99999"  "100000" "100001" "100002"

These labels have a more uniform format.  

Could a change like this be made to data.frame()?

Regards,

-- 
David 

> version
_
platform i686-pc-linux-gnu
arch     i686
os       linux-gnu
system   i686, linux-gnu
status
major    1
minor    8.1
year     2003
month    11
day      21
language R


[Rd] wish list: default row.names in data.frame()
David James