With these toy data, how can I remove unused empty space between the bars? ? #Toy data x1 <- as.data.frame(rep(1:3,?? c(10,2,6))) colnames(x1) <- c("name") x2 <- as.data.frame(rep(5:7,?? c(14,5,8))) colnames(x2) <- c("name") x3 <- as.data.frame(rep(10:12, c(5,5, 8))) colnames(x3) <- c("name") x4 <- as.data.frame(rep(18, 9)) colnames(x4) <- c("name") dat <- rbind.data.frame(x1, x2, x3, x4) dat <- as.data.frame(dat) colnames(data) <- c("name") fix(dat) require(ggplot2) ggplot(dat , aes(x=name, y = ..density..)) + ???????? geom_histogram(colour = "darkgreen", fill = "blue", binwidth = 0.5)? ?? ? Peter Maclean Department of Economics UDSM
On Mon, Jan 6, 2014 at 7:36 PM, Peter Maclean <pmaclean2011 at yahoo.com> wrote:> With these toy data, how can I remove unused empty space between the bars?There is no unused space. It is very hard to see how you could remove the empty space and still have a meaningful graph. Best, Ista> > #Toy data > x1 <- as.data.frame(rep(1:3, c(10,2,6))) > colnames(x1) <- c("name") > x2 <- as.data.frame(rep(5:7, c(14,5,8))) > colnames(x2) <- c("name") > x3 <- as.data.frame(rep(10:12, c(5,5, 8))) > colnames(x3) <- c("name") > x4 <- as.data.frame(rep(18, 9)) > colnames(x4) <- c("name") > dat <- rbind.data.frame(x1, x2, x3, x4) > dat <- as.data.frame(dat) > colnames(data) <- c("name") > fix(dat) > require(ggplot2) > ggplot(dat , aes(x=name, y = ..density..)) + > geom_histogram(colour = "darkgreen", fill = "blue", binwidth = 0.5) > > > > > Peter Maclean > Department of Economics > UDSM > > ______________________________________________ > R-help at r-project.org mailing list > 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.
Use binwidth = 1 -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 1/6/14 4:36 PM, "Peter Maclean" <pmaclean2011 at yahoo.com> wrote:>With these toy data, how can I remove unused empty space between the bars? > >#Toy data >x1 <- as.data.frame(rep(1:3, c(10,2,6))) >colnames(x1) <- c("name") >x2 <- as.data.frame(rep(5:7, c(14,5,8))) >colnames(x2) <- c("name") >x3 <- as.data.frame(rep(10:12, c(5,5, 8))) >colnames(x3) <- c("name") >x4 <- as.data.frame(rep(18, 9)) >colnames(x4) <- c("name") >dat <- rbind.data.frame(x1, x2, x3, x4) >dat <- as.data.frame(dat) >colnames(data) <- c("name") >fix(dat) >require(ggplot2) >ggplot(dat , aes(x=name, y = ..density..)) + > geom_histogram(colour = "darkgreen", fill = "blue", binwidth >0.5) > > > > >Peter Maclean >Department of Economics >UDSM > >______________________________________________ >R-help at r-project.org mailing list >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.