[R] How to plot a bunch of dichotomous code variables in one plot using ggplot2

G.Maubach at weinwolf.de G.Maubach at weinwolf.de
Wed Oct 5 14:46:42 CEST 2016


Hi All,

I have a bunch of dichotomous code variables which shall be plotted in one 
graph using one of their values, this is "1" in this case.

The dataset looks like this:

-- cut --
var1 <- c(1,0,1,0,0,1,1,1,0,1)
var2 <- c(0,1,1,1,1,0,0,0,0,0)
var3 <- c(1,1,1,1,1,1,1,1,0,1)

ds <- data.frame(var1, var2, var3)
-- cut --

I would like to have a bar plot like this



                      *
                      *
                      *
                      *
*                     *
*                     *
*          *          *
*          *          *
*          *          *
*          *          *
-------------------------
var1      var2       var3

If this possible in R? If so, how can I achieve this?

Kind regards

Georg



More information about the R-help mailing list