[R] rownumber

Dimitrios Rizopoulos Dimitris.Rizopoulos at med.kuleuven.be
Sun Sep 10 20:58:18 CEST 2006


maybe the following is what you're looking for:

lead.dat[!duplicate(rownames(lead.dat)), ]

lead.dat[duplicate(rownames(lead.dat)), ]


I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
      http://www.student.kuleuven.be/~m0390867/dimitris.htm


Quoting Ethan Johnsons <ethan.johnsons at gmail.com>:

> # R 2.3.1
>
> I read the data set into R, but the data set have two rows per record.
>
> i.e.
>
> .........
> 105     1       1       1103    1       5       4       8       5       22
> 105     2       2       2       2       1       2       17      16      26
> 106     1       2       606     1       5       12      11      9       37
> 106     2       2       2       2       2       2       16      14      29
> 107     1       3       611     1       7       9       10      7       33
> 107     2       2       2       2       2       2       10      13      29
> ...........
>
> How do you extract the certain columns on the first row set of each?
>
> Tthe first row set are like:
> 105     1       1       1103    1       5       4       8       5       22
> 106     1       2       606     1       5       12      11      9       37
> 107     1       3       611     1       7       9       10      7       33
>
> so, nothing gets imported from the second row set.
>
> 105     2       2       2       2       1       2       17      16      26
> 106     2       2       2       2       2       2       16      14      29
> 107     2       2       2       2       2       2       10      13      29
> I tried:
>
>> a <- subset(lead.dat, rownumber==1)
> Error in eval(expr, envir, enclos) : object "rownumber" not found
>> b <- subset(lead.dat, rownumber==2)
> Error in eval(expr, envir, enclos) : object "rownumber" not found
>
> What is wrong with this?
> thx much
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
>



Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



More information about the R-help mailing list