I am using R and am trying to re-create something like this picture: https://i.redd.it/lrjdj45xrpo21.png
I did some research and saw that the "ggforce" library (Create Parallel Sets diagrams — geom_parallel_sets • ggforce) in R allows the user to make similar styles of plots (plots using the "first name", "middle name" and "last name" - these plots show that the "first name" is really common, the "first name and the middle name" is a bit less common, and the "first name, middle name and last name" is much less common):
library(ggforce)
library(reshape2)
name_data <- data.frame(
"City" = c("Paris", "Paris", "Paris", "Paris", "Paris", "London", "London", "London", "Paris", "London", "Paris"),
"First_Name" = c("John", "John", "John", "John", "John", "John", "James", "James", "Adam", "Adam", "Henry"),
"Middle_Name" = c("Claude", "Claude", "Claude", "Smith", "Smith", "Peters", "Stevens", "Stevens", "Ford", "Tom", "Frank"),
"Last Name " = c("Tony", "Tony", "Frank", "Carson", "Phil", "Lewis", "Eric", "David", "Roberts", "Scott", "Xavier")
)
name_data$ID <- seq.int(nrow(name_data))
data <- reshape2::melt(name_data)
data <- gather_set_data(name_data)
ggplot(name_data, aes(x, id = ID, split = First_Name, value = value)) +
geom_parallel_sets(aes( alpha = 0.3, axis.width = 0.1) +
geom_parallel_sets_axes(axis.width = 0.1) +
geom_parallel_sets_labels(colour = 'white'))
But this returns the following error:
Error in FUN(X[[i]], ...) : object 'x' not found
Can someone please show me what am I doing wrong? Is it possible to show the labels of each group on this graph and the numbers in each group?
Thanks