[R] How to plot a bunch of dichotomous code variables in one plot using ggplot2
Fox, John
jfox at mcmaster.ca
Wed Oct 5 15:01:48 CEST 2016
Dear Georg,
How about barplot(colSums(ds)) ?
Best,
John
-----------------------------
John Fox, Professor
McMaster University
Hamilton, Ontario
Canada L8S 4M4
Web: socserv.mcmaster.ca/jfox
> -----Original Message-----
> From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of
> G.Maubach at weinwolf.de
> Sent: October 5, 2016 8:47 AM
> To: r-help at r-project.org
> Subject: [R] How to plot a bunch of dichotomous code variables in one plot
> using ggplot2
>
> 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
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list