[R] extract submatrix with unique names

2007-02-09 Thread Glazko, Galina
Dear list,

 

I have a table where first 3 columns are identical if the name in the
first column is the same, and 

the number in N4 is slightly different for all identical names, like
this:

---

29Mm.1_at   3  +  93649936

30Mm.1_at   3  +  93649990

31Mm.1_at   3  +  93649993

32Mm.1_at   3  +  93650001

33Mm.1_at   3  +  93650010

34   Mm.10_at   4  + 147438101

35   Mm.10_at   4  + 147438192

36   Mm.10_at   4  + 147438214

37   Mm.100043_at   5  +  31602952

38   Mm.100043_at   5  +  31602982

39   Mm.100043_at   5  +  31603000

 ---

 

I need to select unique identifiers in column N 1, without paying
attention to what is in column N4, taking the first number in N4
corresponding to first unique ID in N1, like this:

29Mm.1_at   3  +  93649936

34   Mm.10_at   4  + 147438101

37   Mm.100043_at   5  +  31602952

 

Could someone tell me how to do it without FOR cycle over all IDs in N1?

 

Thank you!

 

Best regards

Galina

 

 


[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] extract submatrix with unique names

2007-02-09 Thread David Barron
This should do it, assuming you data is in a data frame called dat:

sel - unique(dat$V1)
ix - match(sel,dat$V1)
dat[ix,]


On 09/02/07, Glazko, Galina [EMAIL PROTECTED] wrote:
 Dear list,



 I have a table where first 3 columns are identical if the name in the
 first column is the same, and

 the number in N4 is slightly different for all identical names, like
 this:

 ---

 29Mm.1_at   3  +  93649936

 30Mm.1_at   3  +  93649990

 31Mm.1_at   3  +  93649993

 32Mm.1_at   3  +  93650001

 33Mm.1_at   3  +  93650010

 34   Mm.10_at   4  + 147438101

 35   Mm.10_at   4  + 147438192

 36   Mm.10_at   4  + 147438214

 37   Mm.100043_at   5  +  31602952

 38   Mm.100043_at   5  +  31602982

 39   Mm.100043_at   5  +  31603000

  ---



 I need to select unique identifiers in column N 1, without paying
 attention to what is in column N4, taking the first number in N4
 corresponding to first unique ID in N1, like this:

 29Mm.1_at   3  +  93649936

 34   Mm.10_at   4  + 147438101

 37   Mm.100043_at   5  +  31602952



 Could someone tell me how to do it without FOR cycle over all IDs in N1?



 Thank you!



 Best regards

 Galina






 [[alternative HTML version deleted]]

 __
 R-help@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.



-- 
=
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

__
R-help@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.