Scatterplot interactive x- and y-axis dropdown selection of any variable

Dear community,

I’m new to R plotly library but I’m used to work with ggplot and Shiny apps.

For a project I would like to plot an interactive scatterplot using plotly but I would like to be able to change the variables plotted on the x- and y-axis according to any variable/column in a datatable consisting of up to several hundreds of variables/columns. I don’t know the name of the variables beforehand.

So I would like to ask the community for help to suggest a plotly scatterplot function that can handle any datatable and change the x- and y-axis interactively according to variables/columns.

I’m aware that Shiny can solve the problem but I need a standalone solution within R, R Studio and R Markdown.

A great many thanks for any help!

May be, by accessing the data by column index instead of column name and with a for loop to add a button for each column in range 1 ncol(data)-1 …

Do you have a minimal working example of what you tried with a simple data set so we can try to help you from this ?