Here is what I came up with, similar to a solution proposed here: stacked bars within grouped bar chart
Melt data.frame
and add a new column cat
library(reshape2) # for melt
melted <- melt(test, "person")
melted$cat <- ''
melted[melted$variable == 'value1',]$cat <- "first"
melted[melted$variable != 'value1',]$cat <- "second"
Plot a stacked chart cat
vs value
, faceting by person
. You may need to adjust the labels to get what you want:
ggplot(melted, aes(x = cat, y = value, fill = variable)) +
geom_bar(stat = 'identity', position = 'stack') + facet_grid(~ person)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…