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
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
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)