Black Lives Matter. Please consider donating to Black Girls Code today.

Creating graphs with slider in R

Hello all,

I am new to plotly and I am trying to create graphs with slider. Here is the code, that I tried for test;

f <- list(
  family = "Courier New, monospace",
  size = 18,
  color = "#7f7f7f")

x <- list(title="Longitude", titlefont= f)
y <- list(title="Latitude", titlefon =f)
p <- k %>%
  plot_ly(
    x = ~as.numeric(as.character(LONGITUDE)), 
    y = ~as.numeric(as.character(LATITUDE)), 
    #size = ~HWAM, 
    color = ~HWAM, 
    frame = ~ gsub(".{3}$", "", SDAT), 
    #text = ~country, 
    hoverinfo = "text",
    type = 'scatter',
    mode = 'markers'
    #symbol = ~HWAM, 
    #symbols = c('square')
  ) %>%
  layout(
   xaxis = x , yaxis = y
    )

With this code, I got this plot in R;

In here,
1- I would like to add a base map with only state borders ( with extension on x and y axis)
2- I would like to change the marker symbol from circle to square
3- I don’t know if it’s possible, also I would like to add another slider with matching with years data. For example, for my case (simulating crop yield with different fertilizer application), for each year, I want to show changes in yield (HWAM) respect to different fertilizer application.

Thank you so much for your help in advance.
Nebi