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
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
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
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
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
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
6 matches
Mail list logo