Skip to content
Back to formatted view

Raw Message

Message-ID: <1307490812412-3581189.post@n4.nabble.com>
Date: 2011-06-07T23:53:32Z
From: David A. Johnston
Subject: Sorting Dataframes
In-Reply-To: <1307485944906-3581046.post@n4.nabble.com>

Here's one way:

# Here I read in your data to a variable 'x'
x = read.delim(textConnection(
"Bin Depth Fish
1 4 2
1 8 24
1 12 4
2 4 3
2 8 21
2 12 2
3 4 12
3 8 2
3 12 33"), sep = " ", header = TRUE)


do.call(rbind, lapply(split(x, x$Bin), function(grp)
grp[which.max(grp$Fish),]))

--
View this message in context: http://r.789695.n4.nabble.com/Sorting-Dataframes-tp3580075p3581189.html
Sent from the R help mailing list archive at Nabble.com.