Nicolas -
   I don't think it can be done automatically, but
you can use

row.names(pop) = 1:nrow(pop)

after deleting the column(s) to restore consecutive
numbers for the row names.

                                        - Phil Spector
                                         Statistical Computing Facility
                                         Department of Statistics
                                         UC Berkeley
                                         spec...@stat.berkeley.edu


On Tue, 8 Feb 2011, Nicolas Gutierrez wrote:

Hi All,

I'm trying to delete a row from my dataframe "pop" without changing the indexing (column 0) as follows:

pop

  id birth size xloc yloc weight energy gonad consumed
1   1    36   13   34   43      0     18     0        0
2   2    36   10   39   38      0     18     0        0
3   3    36   10   37   35      0     18     0        0
4   4    36   10   31   25      0     18     0        0
5   5    36   17   34   43      0     18     0        0

By using:

i=3
pop=pop[-pop$id[i],]

  id birth size xloc yloc weight energy gonad consumed
1   1    36   13   34   43      0     18     0        0
2   2    36   10   39   38      0     18     0        0
4   4    36   10   31   25      0     18     0        0
5   5    36   17   34   43      0     18     0        0

But what I really need is:

  id birth size xloc yloc weight energy gonad consumed
1   1    36   13   34   43      0     18     0        0
2   2    36   10   39   38      0     18     0        0
3   4    36   10   31   25      0     18     0        0
4   5    36   17   34   43      0     18     0        0

*note the first column.

Any ideas?

THANKS!!!!

Nico

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to