I want to plot xExp and yExp on the x-axis, with the Yes/Nos as a stacked fill, and the xDur, yDur as the y-axis. Is this possible? Exp = experience and Dur = duration.
This is what I've most recently tried:
ggplot(md1,aes(variable,value,fill=str_detect("Exp")))+
geom_bar(stat="identity")
I melted the dataframe and filtered it and now it looks as below. I have a lot more Exp and Dur values than this, would it make sense to just keep them as separate columns?
md1 <- md %>%
filter(str_detect(variable, paste(c("Exp","Dur"),collapse = '|')))
Subject variable value
1 xExp Yes
2 xExp No
3 xExp Yes
4 xExp Yes
5 xExp No
1 xDur 2
2 xDur NA
3 xDur 1
4 xDur 10
5 xDur NA
1 yExp No
2 yExp No
3 yExp Yes
4 yExp Yes
5 yExp No
1 yDur NA
2 yDur 5
3 yDur 8
4 yDur 2
5 yDur NA
Thank you for any help! I have been searching on here and couldn't find exactly what I needed, but perhaps I was searching for the wrong thing.