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

2016-10-05 Thread Bob Rudis
No need to bring in so many dependencies for a simple ggplot2 marplot: ds <- stack(ds) ggplot(ds[ds$values==1,], aes(ind)) + geom_bar() On Wed, Oct 5, 2016 at 10:17 AM, Thierry Onkelinx wrote: > Here is a ggplot2, tidyr, dplyr solution > > library(tidyr) > library(dplyr) > library(ggplot2) > ds

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

2016-10-05 Thread Ulrik Stervbo
I have a version looking like the original request even library(tidyr) library(ggplot2) 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) ds %>% gather() %>% group_by(key) %>% filter(value > 0) %>% mutate(fake_y = c(1

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

2016-10-05 Thread Bob Rudis
(s/marplot/barplot) On Wed, Oct 5, 2016 at 10:35 AM, Bob Rudis wrote: > No need to bring in so many dependencies for a simple ggplot2 marplot: > > ds <- stack(ds) > ggplot(ds[ds$values==1,], aes(ind)) + geom_bar() > > On Wed, Oct 5, 2016 at 10:17 AM, Thierry Onkelinx < > thierry.onkel...@inbo.be

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

2016-10-05 Thread Thierry Onkelinx
Here is a ggplot2, tidyr, dplyr solution library(tidyr) library(dplyr) library(ggplot2) ds %>% gather() %>% group_by(key) %>% summarize(total = sum(value)) %>% ggplot(aes(x = key, y = total)) + geom_bar(stat = "identity") ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Re

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

2016-10-05 Thread G . Maubach
Hi Bob, Hi John, Hi readers, many thanks for your reply. I did barplot(colSums(dataset %>% select(FirstVar:LastVar))) and it worked fine. How would I do it with ggplot2? Kind regards Georg Von:"Fox, John" An: "g.maub...@weinwolf.de" , Kopie: "r-help@r-project.org" Datum: 05.