Plotly argument error executing in RStudio

This following error occurs in when executing in RStudio, but not when executing the same code at the CLI.
Error in match.arg(on, paste0(“plotly_”, c(“click”, “hover”, “selected”)))

I'm following the plotly-r manual from https://plotly-r.com/preface.html and the first example using plotly is

library(plotly)
m <- highlight_key(mpg)
p <- ggplot(m, aes(displ, hwy)) + geom_point()
gg <- highlight(ggplotly(p), "plotly_selected")
crosstalk::bscols(gg, DT::datatable(m))

I get the error above.

I have RStudio 1.3.1093. My R version (if independent) is 4.0.3. I’m on macOS Mojave 10.14.6.

Is this a known problem for which there is a work-around, or must I just stick to the CLI for these examples?

My advice is to run one line of the code at a time so you can identify which row causes the issue...

Additionally, you should check you have the latest package versions.

I think the problem may have been that I had just previously run the preceding code in the tutorial to produce a graph.

library(ggplot2)
ggplot(mpg, aes(displ, hwy)) + geom_point()

This plot was still in the viewer quadrant of RStudio, either under Plots or Viewer. This time I deleted the plot before proceeding. Does this make sense, or should I watch for some other problem in my previous RStudio session?

You could test that theory by running the two codes in order again... I wouldn't expect any problems.

You were right. I ran the code of each sequence in turn, first generating the ggplot in the 'Plots' window, then the crosstalk::bscols output in the 'Viewer' window.

In between, I had done a check for package updates. There was one package that had a newer non-compiled version, so I downloaded and compiled that. There doesn't seem to be a log. Maybe I'm looking in the wrong place.

I think it was at that stage RStudio suggested I save my environment and restart. RStudio never returned, so I eventually force-quit. Everything that has been working has occurred since the forced restart.

Early in that aborted session, I had downloaded the 1.74Gb Main table main.csv file from GoogleCloudPlatform/covid-19-open-data (https://storage.googleapis.com/covid19-open-data/v2/main.csv) and read.csv'd it into RStudio. That took a while. Whether that had stressed some component to breaking, I don't know.

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.