> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of Jim Lemon
> Sent: Thursday, March 18, 2010 1:33 AM
> To: duncandonutz
> Cc: r-help@r-project.org
> Subject: Re: [R] Using indexing to manipulate data
>
Here are two solutions. The first uses merge and the second uses
sqldf. They both do a self join picking off the unique pairs. The
sqldf solution also sorts the result:
# input
DF <- structure(list(Actor = c("Jim", "Bob", "Bob", "Larry", "Alice",
"Tom", "Tom", "Tom", "Alice", "Nancy"), Act = c(
One approach is the following:
Dat <- read.table(textConnection(
"Jim A
BobA
BobC
Larry D
Alice C
Tom F
Tom D
Tom A
Alice B
NancyB"))
closeAllConnections()
names(Dat) <- c("name", "act")
out <- tapply(as.character(Dat$name), Dat$act,
On 03/18/2010 04:05 PM, duncandonutz wrote:
I know one of R's advantages is it's ability to index, eliminating the need
for control loops to select relevant data, so I thought this problem would
be easy. I can't crack it. I have looked through past postings, but
nothing seems to match this pro
I know one of R's advantages is it's ability to index, eliminating the need
for control loops to select relevant data, so I thought this problem would
be easy. I can't crack it. I have looked through past postings, but
nothing seems to match this problem
I have a data set with one column of act
5 matches
Mail list logo