1

I have two column data

Year    Total

1945    88
1946    109
1947    55

I would like R to return the Year value for maximum value of Total. For the above data, R should return 1946.

How do I d this?

Thanks,

jcel

Konrad Krakowiak
  • 12,285
  • 11
  • 58
  • 45
Jim
  • 11
  • 2

1 Answers1

2

Given:

df<-data.frame(year=c(1945,1946,1947),total=c(88,109,55))

then:

maxYear<-subset(df,df$total==max(df$total),select=year)
Andrew Taylor
  • 3,438
  • 1
  • 26
  • 47