My tibble looks like this:
# A tibble: 5 × 6
clusters neuroticism introverty empathic open unconscious
<int> <dbl> <dbl> <dbl> <dbl> <dbl>
1 1 0.242 1.02 0.511 0.327 -0.569
2 2 -0.285 -0.257 -1.36 0.723 -0.994
3 3 0.904 -0.973 0.317 0.0622 -0.0249
4 4 -0.836 0.366 0.519 0.269 1.00
5 5 0.0602 -0.493 -1.03 -1.53 -0.168
I was wondering how I can plot this with ggplot2, so that It looks like the big five personality profiles shown in this picture:
My goal is to plot an personality profile for each cluster.
Thanks in advance!
>Solution :
In order to plot it you’d typically need to have the data in a long format. A tidyverse-solution using pivot_longer and then ggplot could look like:
df |>
pivot_longer(-clusters) |>
ggplot(aes(x = name,
y = value,
fill = as.factor(clusters))) +
geom_col(position = "dodge")
Plot:
Data:
df <-
tribble(
~clusters,~neuroticism,~introverty,~empathic,~open,~unconscious,
1,0.242,1.02,0.511,0.327,-0.569,
2,-0.285,-0.257,-1.36,0.723,-0.994,
3,0.904,-0.973,0.317,0.0622,-0.0249,
4,-0.836,0.366,0.519,0.269,1.00,
5,0.0602,-0.493,-1.03,-1.53,-0.168
)

