library('ggplot2')
library('reshape2')
df <- reshape2::melt(df, id.vars = 'ID') # melt data with ID column
df <- df[!is.na(df$value), ] # remove NA
ggplot( data = df, aes( x = ID, y = value )) +
geom_bar( aes( fill = variable ), stat = 'identity' )
Data:
df <- structure(list(ID = c("D11", "D170", "D171", "D1", "D27", "D295"),
A = c(2L, 2L, 1L, 5L, NA, 0L),
B = c(2L, 0L, 5L, 0L, NA, 6L),
C = c(4L, 6L, 2L, 2L, NA, 2L)),
.Names = c("ID", "A", "B", "C"),
row.names = c(NA, -6L), class = "data.frame")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…