Converting of Chord diagram into Plotly object in R

85 Views Asked by At

I am attempting to convert a Chord diagram into a Plotly object because I plan to use it in a Shiny application later. I have tried the steps explained below, but without any success. Can anybody help me figure out how to solve this problem and convert this plot into a Plotly object?

library(circlize)
library(sfo)
library(cowplot)
library(plotly)

random_values<-c(500:100)

random_sample<-sample(random_values,15)

col.pal = c(BMW = "red",
            Honda = "green",
            Nissan = "blue",
            Tesla = "grey",
            Toyota = "maroon",
            Phoenix = "grey",
            Tucson = "black",
            Sedona = "grey"
              )
ChordPlot <- matrix( 
                    random_sample,
                    nrow = 5,
          dimnames = list(c("BMW","Honda","Nissan","Tesla","Toyota"),
                          c("Phoenix","Tucson","Sedona")))

# Converting to object
 ChordPlot <- recordPlot()

# Converting to Plotly object                            
 ChordPlot <- ggplotly(ChordPlot)

And the end I received this error

Error in UseMethod("ggplotly", p) : 
  no applicable method for 'ggplotly' applied to an object of class "recordedplot"

Can anybody help me how to solve this problem and produce plotly object ?

0

There are 0 best solutions below