Re: [R] Subsetting to unique values

2008-06-06 Thread Jorge Ivan Velez
Dear Paul, Try also: ddTable <- data.frame(Id=c(1,1,2,2),name=c("Paul","Joe","Bob","Larry")) ddTable[unique(ddTable$Id),] HTH, Jorge On Fri, Jun 6, 2008 at 9:35 AM, Emslie, Paul [Ctr] <[EMAIL PROTECTED]> wrote: > I want to take the first row of each unique ID value from a data frame. > For

Re: [R] Subsetting to unique values

2008-06-06 Thread jim holtman
The interesting thing about R is that there are several ways to "skin the cat"; here is yet another solution: > do.call(rbind, by(ddTable, ddTable$Id, function(z) z[1,,drop=FALSE])) Id name 1 1 Paul 2 2 Bob > On Fri, Jun 6, 2008 at 9:35 AM, Emslie, Paul [Ctr] <[EMAIL PROTECTED]> wrote: > I

Re: [R] Subsetting to unique values

2008-06-06 Thread Adrian Dusa
Emslie, Paul [Ctr] atac.mil> writes: > > I want to take the first row of each unique ID value from a data frame. > For instance > > ddTable <- > data.frame(Id=c(1,1,2,2),name=c("Paul","Joe","Bob","Larry")) > > I want a dataset that is > IdName > 1 Paul > 2 Bob > > > unique(ddTable

Re: [R] Subsetting to unique values

2008-06-06 Thread John Kane
I don't have R on this machine but will this work. myrows <- unique(ddTable[,1]) unis <- ddTable(myrows, ] --- On Fri, 6/6/08, Emslie, Paul [Ctr] <[EMAIL PROTECTED]> wrote: > From: Emslie, Paul [Ctr] <[EMAIL PROTECTED]> > Subject: [R] Subsetting to unique valu

Re: [R] Subsetting to unique values

2008-06-06 Thread Chuck Cleland
On 6/6/2008 9:35 AM, Emslie, Paul [Ctr] wrote: I want to take the first row of each unique ID value from a data frame. For instance ddTable <- data.frame(Id=c(1,1,2,2),name=c("Paul","Joe","Bob","Larry")) I want a dataset that is Id Name 1 Paul 2 Bob unique(ddTable) Will give m

[R] Subsetting to unique values

2008-06-06 Thread Emslie, Paul [Ctr]
I want to take the first row of each unique ID value from a data frame. For instance > ddTable <- data.frame(Id=c(1,1,2,2),name=c("Paul","Joe","Bob","Larry")) I want a dataset that is Id Name 1 Paul 2 Bob > unique(ddTable) Will give me all 4 rows, and > unique(ddTable$Id) Will