I'm coming here because after hours of research and failed trials, i dont know what to do next.
I've a database (opened via dyplr
with the open_excel command) that looks like the one below (but more complexe with more variables) :
> dput(open)
structure(list(Subject = c(1, 2, 3, 4, 5), `Happy - Before` = c(4,
4, 2, 1, 7), `Courageous - Before` = c(5, 2, 1, 3, 4), `Strange - Before` = c(1,
2, 1, 4, 6), `Happy - After` = c(4, 2, 6, 2, 2), `Courageous - After` = c(7,
1, 5, 1, 2), `Strange - After` = c(3, 7, 4, 5, 4)), row.names = c(NA,
-5L), class = c("tbl_df", "tbl", "data.frame"))
# A tibble: 5 x 7
Subject `Happy - Before` `Courageous - B… `Strange - Befo… `Happy - After`
<dbl> <dbl> <dbl> <dbl> <dbl>
1 1 4 5 1 4
2 2 4 2 2 2
3 3 2 1 1 6
4 4 1 3 4 2
5 5 7 4 6 2
# … with 2 more variables: `Courageous - After` <dbl>, `Strange - After` <dbl>
My goal here is to plot a density graph with some specificity :
Density of scores obtained by all the subjects for each ability trait on a scale from 1 to 7
As you can see on my (awful) graph, i'm trying to display the responses of all my subjects on a scale from 1 to 7 (x axis) via a density plot, but for each trait i have (y - axis), and thus, with a separation from responses made before [a test] and after a test. And i need to get the same kind of legend (courageous shown to the left, not courageous shown to the right). The more a participant is close to 7 when he answer to the scale, the more he is [happy, courageous, depressed, anxious....] and the more he get close to 1, the more he is [not happy, not courageous, not depressed...]
I tried my best (using ggplot2
templates, trying to melt things and all but i fairly new to R and language programming :/)
All my variables have thos kind of name : [trait1]_before
, [trait2]_before
, [trait1]_After
, [trait2]_After
I hope this post is clear. If not, i will be glad to add informations ! Thank you everyone (sorry for my pooor english)