R plotly plot with mode = 'lines' or mode = 'markers'

In my plot, I only wish to have the markers ONLY at certain specific points, while the rest are without markers, is that possible? For example:
I only want to have markers at those points with red circles.

I have thought of using ifelse inside like this, but it does not work.

p <- plot_ly(data = DailyRainFall, 
              x = ~Date, y = ~DailyRainFall,
              type = 'scatter', mode = ifelse(DailyRainFall$DailyRainFall>5000,'markers','lines')) %>% 
     plotly::config(displayModeBar = FALSE) %>% 
     layout(title = "Daily Rainfall in year 2021",
            xaxis = list(title = ''),
            yaxis = list(title = "Daily Rainfall (mm)"))
 p
Error in vapply(traces, function(tr) tr$mode %||% "lines", character(1)) : 
  values must be length 1,
 but FUN(X[[1]]) result is length 272

Any help would be appreciated. If we cannot specific threshold to determine whether to use lines or markers, can we selectively choose those data point we want with markers, and combine with the main plot with lines? If yes, how can this be achieved?
Thanks.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.