I have a dataset with two columns. One is the data category and one is my samples. I am using mtcars as an example
library(circlize)
library(data.table)
mtCARS<- mtcars
setDT(mtCARS, keep.rownames = TRUE)[]
mtCARS1<- mtCARS[,c(1,11)]
colnames(mtCARS1)<- c("Brand", "gear")
now lets say I'm interested in the car names (now called Brand) as being my samples and gear being the category. I want two things
1. The chords emanating from the category, in this case the gear to be three colours, corresponding to the category number.
2. The grid colour for all the samples (in this case brand) to be the same colour.
If you where to execute
chordDiagram(as.data.frame(mtCARS1)
you get random colour assignment for everything and chords emanating from the categories (Brand) would be multiply coloured.
Now the above command needs to be executed (I think) as below
chordDiagram(as.data.frame(mtCARS1), col=col, grid.col = grid.col)
note that I have defined the col and grid.col function, which I believe need to be defined to address my points 1 and 2 respectively this is where I'm having problems.
so far for the chord colour (point 1) I have tried the below but it didn't work
library(RColorBrewer)
col<- colorRampPalette(c("red", "green", "blue"), space= "rgb")(30)
for the grid colour (point 2) I have tried
othercol<- as.character(mtCARS1[,1])
grid.col = c("4" = "red", "3" = "green", "5" = "yellow", othercol = "blue")
This gets me the category (gear) colour which I want, but for the sample colours (Brand), the grid colours are not blue.
please note that my actual data is loaded as a data frame and not a matrix.
NOTE: The solution to point one is to reverse the order of columns since it is the first column that defines the number of colours used. Hence do
mtCARS1<- mtCARS[,c(11,1)]