Simple violin plot throws an error

This example from plotly documentation given an error -

"Error: Trace type must be one of the following:
‘scatter’, ‘box’, ‘bar’, ‘heatmap’, ‘histogram’, ‘histogram2d’, ‘histogram2dcontour’, ‘pie’, ‘contour’, ‘scatterternary’, ‘sankey’, ‘scatter3d’, ‘surface’, ‘mesh3d’, ‘scattergeo’, ‘choropleth’, ‘scattergl’, ‘pointcloud’, ‘heatmapgl’, ‘parcoords’, ‘scattermapbox’, ‘carpet’, ‘scattercarpet’, ‘contourcarpet’, ‘ohlc’, ‘candlestick’, ‘area’


library(plotly)

df <- read.csv(“https://raw.githubusercontent.com/plotly/datasets/master/violin_data.csv”)

p <- df %>%
plot_ly(
y = ~total_bill,
type = ‘violin’,
box = list(
visible = T
),
meanline = list(
visible = T
),
x0 = ‘Total Bill’
) %>%
layout(
yaxis = list(
title = “”,
zeroline = F
)
)

Any help to troubleshoot will be greatly appreciated.

Thanks,
Praveen.

I am using

library(plotly)
packageVersion(‘plotly’)
[1] ‘4.7.1’

HI @psurendran629

You need the dev version: devtools::install_github("ropensci/plotly")

see here for more info.

Thanks. Tried but got this error after installation -

Error: package or namespace load failed for ‘plotly’ in get(Info[i, 1], envir = env):

lazy-load database ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/ggplot2/R/ggplot2.rdb’ is corrupt

In addition: Warning message:

In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1​

Let me try it again.

hmmm I’ve seen this happen a few times. Generally, I uninstall packages, restart the R environment and reinstall new packages to avoid this. Perhaps give that a shot and see it if works for you.