search for: geom_bar

Displaying 20 results from an estimated 67 matches for "geom_bar".

2017 Jul 27
2
na.rm = T treatment by ggplot2's geom_bar
To clarify: my question is not about "who could I exclude NAs from being counted" - I know how to do that. My question is: Why na.rm = T is not working for geom_bar in this case? On Thu, Jul 27, 2017 at 8:24 AM, Dimitri Liakhovitski < dimitri.liakhovitski at gmail.com> wrote: > Hello! > > I am trying to understand how ggplot2's geom_bar treats NAs. > The help file says: > > library(ggplot2) > ?geom_bar > na.rm: If FALSE, the...
2017 Jul 27
1
na.rm = T treatment by ggplot2's geom_bar
...e my brevity. On July 27, 2017 7:49:47 AM PDT, Dimitri Liakhovitski <dimitri.liakhovitski at gmail.com> wrote: >To clarify: my question is not about "who could I exclude NAs from >being >counted" - I know how to do that. >My question is: Why na.rm = T is not working for geom_bar in this case? > >On Thu, Jul 27, 2017 at 8:24 AM, Dimitri Liakhovitski < >dimitri.liakhovitski at gmail.com> wrote: > >> Hello! >> >> I am trying to understand how ggplot2's geom_bar treats NAs. >> The help file says: >> >> library(ggplot2)...
2017 Jul 27
1
na.rm = T treatment by ggplot2's geom_bar
...comic strip ) On Thu, Jul 27, 2017 at 7:49 AM, Dimitri Liakhovitski <dimitri.liakhovitski at gmail.com> wrote: > To clarify: my question is not about "who could I exclude NAs from being > counted" - I know how to do that. > My question is: Why na.rm = T is not working for geom_bar in this case? > > On Thu, Jul 27, 2017 at 8:24 AM, Dimitri Liakhovitski < > dimitri.liakhovitski at gmail.com> wrote: > >> Hello! >> >> I am trying to understand how ggplot2's geom_bar treats NAs. >> The help file says: >> >> library(ggplot2...
2017 Jul 27
1
na.rm = T treatment by ggplot2's geom_bar
Thank you, Bert! I do NOT have an object named "T" in scope (I checked - and besides, it would never occur to me to use this name). TRUE or T results in the same unexpected behavior: ggplot(data = md, mapping = aes(x = a)) + geom_bar(na.rm = TRUE) On Thu, Jul 27, 2017 at 10:57 AM, Bert Gunter <bgunter.4567 at gmail.com> wrote: > Just a thought: > > Did you try na.rm = TRUE in case you have an object named "T" in scope? > > -- Bert > > > Bert Gunter > > "The trouble with ha...
2017 Jul 27
1
na.rm = T treatment by ggplot2's geom_bar
Hello! I am trying to understand how ggplot2's geom_bar treats NAs. The help file says: library(ggplot2) ?geom_bar na.rm: If FALSE, the default, missing values are removed with a warning. If TRUE, missing values are silently removed. I am trying it out: md <- data.frame(a = c(letters[1:5], letters[1:4], letters[1:3], rep(NA, 3))) str(md); levels(md...
2017 Jul 27
1
na.rm = T treatment by ggplot2's geom_bar
...tski at gmail.com> wrote: >Thank you, Bert! > >I do NOT have an object named "T" in scope (I checked - and besides, it >would never occur to me to use this name). >TRUE or T results in the same unexpected behavior: > >ggplot(data = md, mapping = aes(x = a)) + > geom_bar(na.rm = TRUE) > > > >On Thu, Jul 27, 2017 at 10:57 AM, Bert Gunter <bgunter.4567 at gmail.com> >wrote: > >> Just a thought: >> >> Did you try na.rm = TRUE in case you have an object named "T" in >scope? >> >> -- Bert >> >&...
2017 Jul 27
1
na.rm = T treatment by ggplot2's geom_bar
...ank you, Bert! > > > >I do NOT have an object named "T" in scope (I checked - and besides, it > >would never occur to me to use this name). > >TRUE or T results in the same unexpected behavior: > > > >ggplot(data = md, mapping = aes(x = a)) + > > geom_bar(na.rm = TRUE) > > > > > > > >On Thu, Jul 27, 2017 at 10:57 AM, Bert Gunter <bgunter.4567 at gmail.com> > >wrote: > > > >> Just a thought: > >> > >> Did you try na.rm = TRUE in case you have an object named "T" in > &...
2017 Jun 27
3
ggplot2 geom_bar arrangement
Hi, I was trying to draw a geom_bar plot. However, by default, the bars are arranged according to the label, which I don't want. I want the bars to appear exactly as they appear in the data frame. For example in the code: Lab=c(letters[4:6],letters[1:3]) valuex = c(3.1,2.3,0.4,-0.4,-1.2,-4.4) df <- data.frame(Lab,valuex)...
2017 Jun 27
1
ggplot2 geom_bar arrangement
...c(letters[4:6], letters[1:3]) valuex = c(3.1,2.3,0.4,-0.4,-1.2,-4.4) df <- data.frame(Lab,valuex) # set the factor levels to the same order as observed in the data frame df$Lab <- factor(df$Lab, levels=unique(df$Lab)) px <- ggplot(df,aes(Lab,valuex,label=Lab)) + geom_text(aes(y=0)) + geom_bar(stat = "identity") px Jean On Tue, Jun 27, 2017 at 1:43 PM, Brian Smith <bsmith030465 at gmail.com> wrote: > Hi, > > I was trying to draw a geom_bar plot. However, by default, the bars are > arranged according to the label, which I don't want. I want the bars to &...
2012 Jan 29
2
ColorBrewer question
...t;seq", pal = "Blues")" with no effect. This is my code:   p <- ggplot(data, aes(x = gender))  + scale_y_continuous("",formatter="percent") + xlab("Gender") + coord_flip() +     scale_colour_brewer(type="seq", pal = "Blues") p+geom_bar(aes(fill=pet),colour=''black'',position=''fill'')     Any ideas welcome. Thanks,  Mario [[alternative HTML version deleted]]
2011 Nov 16
2
geom_bar with missing data in package ggplot
...3L, 169L, 170L, 171L, 206L, 207L, 208L, 354L, 355L, 356L), class = "data.frame") gp <- ggplot(g, aes(Date, value)) gp<- gp + geom_line() gp <-gp + facet_grid(var2 ~ variable) gp this works, but trying to get a bar chart version gp <- ggplot(g, aes(Date, value)) gp<- gp + geom_bar(stat="identity") gp <-gp + facet_grid(var2 ~ variable) gp gives the error Error in if (!is.null(data$ymin) && !all(data$ymin == 0)) warning("Stacking not well defined when ymin != 0", : missing value where TRUE/FALSE needed Is there something I can do to have...
2013 Feb 03
2
ggplot2 plotting errorbars.
Hi, i''m using this lines of code: dodge <-position_dodge(width=0.9) ggplot(dfm,aes(x = X,y = value)) + geom_bar(aes(fill = variable), position=dodge, stat="identity") + geom_errorbar(aes(ymin=value-er, ymax=value+er),width=0.25, position=dodge,stat="identity") to plot this data frame X variable value er 1 A X4 58.74 9.44 2 B X4 52.41 10.01 3 C X...
2009 Dec 04
8
[ggplot2] Wind rose orientation
...ding what I need. Any help much appreciated. Here is the code from my Org-babel session: #+begin_src R :session library(ggplot2) wind.data <- read.csv("pmrf_windrose_info_new.csv") wind <- ggplot(wind.data, aes(x = degree, y = time, fill = wind)) wind.bar <- wind + geom_bar(stat = "identity") wind.bar + coord_polar() #+end_src All the best, Tom Thomas S. Dye, Ph.D. T. S. Dye & Colleagues, Archaeologists, Inc. Phone: (808) 529-0866 Fax: (808) 529-0884 http://www.tsdye.com [[alternative HTML version deleted]]
2010 Mar 12
1
simple plot in ggplot2, wrong error bars
...d", "removed")), coon = c(0.093, 0.06, 0.057, 0.09), group = factor(c("veget", "fruit", "veget", "fruit")), se = c(0.01, 0.01, 0.02, 0.026)) limits <- aes(ymax = coon + se, ymin=coon - se) p<-ggplot(df, aes(fill=group, y=coon, x=trt)) p+geom_bar(position="dodge",stat="identity") dodge <- position_dodge(width=0.9) > p + geom_bar(position="dodge") + geom_errorbar(limits, position="dodge", > width=0.5) as you noticed the code above gets the error bars in the wrong columns. So I used the code...
2017 Jun 27
0
ggplot2 geom_bar label justification
...st <- ifelse(df1$valuex > 0, 1.3, -0.3) df1$Lab1 <- factor(df1$Lab1, levels = unique(df1$Lab1)) df1$Lab2 <- factor(df1$Lab2, levels = unique(df1$Lab2)) ## plot 1 px <- ggplot(df1,aes(Lab,valuex,label=Lab1,hjust = hjust)) + geom_text(aes(y=0,size=5)) + geom_bar(stat = "identity") px <- px + coord_flip() ## plot 2 py <- ggplot(df1,aes(Lab,valuex,label=Lab2,hjust = hjust)) + geom_text(aes(y=0,size=5)) + geom_bar(stat = "identity") py <- py + coord_flip() ######### many thanks for your help! [...
2012 Nov 30
1
Changing the base of geom_bar in ggplot
...e average. I can do that by subtracting the average from each value but I would like to have the zero line as the average to make it more clear. How do you change the ''base''-line? x <- data.frame(val=c(1.5, 3, -1.4, -1, 2), lab=letters[1:5]) ggplot(data=x, aes(x=lab, y=val)) + geom_bar(stat="identity") Many thanks for your help! Best regards, Werner -- View this message in context: http://r.789695.n4.nabble.com/Changing-the-base-of-geom-bar-in-ggplot-tp4651407.html Sent from the R help mailing list archive at Nabble.com.
2009 Feb 02
7
Broke ggplot...
...ale") VADeaths_flat_df<-rbind(VADeaths_flat_tmp1, VADeaths_flat_tmp2) VADeaths_flat_df<-rbind(VADeaths_flat_df, VADeaths_flat_tmp3) VADeaths_flat_df<-rbind(VADeaths_flat_df, VADeaths_flat_tmp4) bin_size<-15.0 ggplot(VADeaths_flat_df, aes(x = factor(Data), fill = factor(Person))) + geom_bar(position=position_dodge(width =(20)), binwidth=20) # or ggplot(VADeaths_flat_df, aes(x=factor(Data))) + geom_histogram(binwidth=20)    Thanks again for any feedback you provide. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org m...
2017 Aug 13
1
ggplot's aes_ doesn't work as expected for x=factor()
...0.01, 0.01, 1, 1, 30, 30), pct1 = c(12, 88, 60, 40, 93, 7), Var2 = c(2, 2, 4, 4, 8, 8), pct2 = c(43, 57, 10, 90, 50, 50) ) varnames <- names(df) # using aes()--this works ggplot(df, aes(x=factor(Var1), y=pct1, fill=LogicalVar)) + geom_bar(stat="identity") # works # using aes_() works in this instance ggplot(df, aes_(x=as.name(varnames[2]), y=as.name(varnames[3]), fill=as.name(varnames[1]))) + geom_bar(stat="identity") # works # it doesn't work here, where only change is using x=factor() ggplot(df, aes_(x=...
2018 Jan 15
3
barplot that displays sums of values of 2 y colums grouped by different variables
...in each bar as a label? I aggregated the data into sums like this: sum_data <- aggregate(. ~ City,data=raw_data,sum) this gave me the sums per city as I wanted but for some reason 1 of the cities is missing in the output. Using this code for the plot: ggplot(sum_data,aes(x = City,y = n)) + geom_bar(aes(fill = y),stat = "identity",position = "dodge") gave be a bar plot with one bar per city showing the sum of y as a color gradient. not what I expected given the "dodge" command in geom_bar. Thanks.
2010 Mar 09
5
ggplot2 rose diagram
Dear R gurus - consider this plot: library(ggplot2) dat <- sample(1:8,100,replace=TRUE) smp <- ggplot(data.frame(dat), aes(x=factor(dat),fill=factor(dat))) + geom_bar(width=1) smp + coord_polar() Q1. How do I change the font size and weight of bar labels (1,2,3...)? I''ve been wallowing in the ''Themes'' structure and I just can''t figure out the correct place to change the definitions. Along these same lines, what does '&...