I have the following framework:
sales<-c(1,2,3,45,4,3,21)
price<-c(35,45,30,10,33,44,15)
df<-data.frame(sales,price)
I am looking for a way to find the appropriate price maximum salesone as well as it row numberand write them down like aand b.
For example, the maximum salesis 45. This is when it priceis 10 (a must be 10), and this record is on the 4th line (b must be 4).
> a
[1] 10
> b
[1] 4
source
share