r - Bar chart with several non mutually exclusive characteristics -


i have data set variable has several other characteristics, not mutually exclusive. here's data.

df <- structure(list(cont1 = structure(c(2l, 2l, 4l, 1l, 2l, 3l, 2l, 4l, 4l, 1l, 2l, 2l, 4l, 1l, 1l, 2l, 2l), .label = c("africa", "asia", "europe", "lac"), class = "factor"), sids = structure(c(2l, 1l, 2l, 1l, 1l, 1l, 2l, 2l, 2l, 2l, 1l, 2l, 2l, 2l, 2l, 2l, 2l), .label = c("no", "sids"), class = "factor"), ldc = structure(c(2l, 1l, 2l, 1l, 2l, 2l, 1l, 2l, 2l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l), .label = c("ldc", "no"), class = "factor")), .names = c("cont1", "sids", "ldc"), class = "data.frame", row.names = c(na, -17l)) 

so when put long format df.m <- melt(df, id.vars = c("cont1")) can build plot ggplot2 nas in plot. if exclude them proportions distorted because there more nas in 1 of categories.

ggplot(df.m, aes(x = cont1, fill = value)) + geom_bar() ggplot(df.m[df.m$value != "no",], aes(x = cont1, fill = value)) + geom_bar() 

is there way have bar plot of variable cont1 value fill without nas distorting proportion? can use different length fill in ggplot2?


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

monitor web browser programmatically in Android? -

c# - Using multiple datasets in RDLC -