I have recorded the answers, in the form of a Likert scale from 0 to 10, of ten subjects regarding a specific believe "before" and "after" a treatment. The answers, as well as the sex assigned at birth, have been stored in a df where column 1 contains the ID of the participant, column 2 encodes whether the answer was taken "before" or "after" the treatment, column 3 the sex at birth ad column 4 the actual score.
I would like to make a representation of the variation of the scale in this way:
- A circle with a scale from 0 to ten
- for each subject, a line connect the initial value (i.e. "Before") with the final value (i.e. "After")
- these lines are differently filled based on the sex status.
Here is the data frame
df <- data.frame(
ID= c(1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10),
Time = c("before","after","before","after","before","after","before","after","before","after","before","after","before","after","before","after","before","after","before","after"),
Group = c("Male","Male","Male","Male","Male","Male","Male","Male","Male","Male","Female","Female","Female","Female","Female","Female","Female","Female","Female","Female"),
Score = c(0,4,1,5,3,7,0,0,0,2,1,9,1,9,1,8,1,8,1,4)
)
I have tried to use library(circlize) I create a new database with the two columns set aside ad used chordDiagram, which has produced the image attached.
library(circlize)
library(dplyr)
dfBefore <- df %>% filter(Time=="before")
dfAfter <- df %>% filter(Time=="after")
dfMerged <- data.frame(Before=dfBefore$Score, After=dfAfter$Score)
The probem is that the "values" on the circle are represented bigger as the number of people who fall in that category (the zero and one section are very large), while
- every number of the scale should be represented with the same dimension (and from each number should depart arrows representing each subject)
- arrow or linkers should be filled by different colors regarding the value Sex
- It would be nice to represent also the amount of people who don't experience any change in th score (as 0->0), may be with a circled arrow that start and end in the same number.
I would like to thank everyone who may help me.