I have a plot,where y-axis are obervations and x-axis is time. I have to find the maximun (x,y point) from the plot. I used max(), but I only figured out the obervation value but not the time point where this max obervation value is. Could someone help me please?
Try this example, using base plot:

    # dummy data
    df1 <- mtcars[1:10, 1:2]
    
    # plot
    plot(df1$mpg, df1$cyl)
    
    # get the max on y, and matching x value
    df1Max <- df1[ which(max(df1$cyl) == df1$cyl), ]
    
    # mark the max point on the plot
    points(df1Max$mpg, df1Max$cyl, col = "red", pch = 19)
    
    # add vertical line
    abline(v = df1Max$mpg, col = "blue", lty = "dashed")


![enter image description here][1]


  [1]: https://i.imgur.com/jYTqdPm.jpg