-2

I'm looking for a way to find the maximum value of a column, but only in rows where a different column equals a given value.

sgibb
  • 25,396
  • 3
  • 68
  • 74
user3347232
  • 407
  • 1
  • 7
  • 16
  • To explain the downvotes: You could found the answer easily by reading an introduction to the language. Please do some research before asking a question. – Roland Feb 27 '14 at 14:51
  • Welcome to SO! People are generally much more happy to help if you provide a [**minimal, reproducible example**](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610) together with the **code you have tried**. Also have a look at [a nice **checklist for questions** on SO](http://meta.stackexchange.com/questions/156810/stack-overflow-question-checklist). Cheers. – Henrik Feb 27 '14 at 14:57

1 Answers1

0

Suppose all your data is stored in a data frame called dat

max(dat$columnYouWantMaxOf[dat$columnYouWantToHaveSpecificValue==ValueYouWantThisColumnToHave])
Steve Reno
  • 1,304
  • 3
  • 14
  • 21