Chord Diagram stored as data frame in R

37 views Asked by At

I am trying to using a Chord Diagram in R. Below you can see my data and my code :

library(circlize)
library(sfo)
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"
              )
Sample_Matrix <- matrix( 
                    random_sample,
                    nrow = 5,
          dimnames = list(c("BMW","Honda","Nissan","Tesla","Toyota"),
                          c("Phoenix","Tucson","Sedona")))

So far so good. But I face with problem in the next row.

TestPlot<-chordDiagram(Sample_Matrix,grid.col = col.pal)

Namely when I execute this command immediately chart will appear in the pane for Plots. But when I press on TestPlot I was surprised to see that output is data frame, instead of object with plot.

class(TestPlot)
[1] "data.frame"

This plot I want to use in Shiny app, and therefore I must to have object. Can anybody help me how to solve this problem ?

0

There are 0 answers