Displaying 20 results from an estimated 179 matches for "geom_bar".
2017 Jul 27
3
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
0
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
2
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
0
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
2
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
>>
>&...
2007 Aug 08
1
Help using gPath
....309
labels.gTree.315:: (label.text.312, label.text.314)
strip.gTree.364:: (background.rect.361, label.text.363)
strip.gTree.370:: (background.rect.367, label.text.369)
guide.rect.357
guide.rect.358
boxplots.gTree.283::
geom_boxplot.gTree.273:: (GRID.segments.267, GRID.segments.268,
geom_bar.rect.270, geom_bar.rect.272)
geom_boxplot.gTree.281:: (GRID.segments.275, GRID.segments.276,
geom_bar.rect.278, geom_bar.rect.280)
boxplots.gTree.301::
geom_boxplot.gTree.291:: (GRID.segments.285, GRID.segments.286,
geom_bar.rect.288, geom_bar.rect.290)
geom_boxplot.gTree.299:: (GRID.seg...
2017 Jul 27
0
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
4
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
0
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 Aug 10
1
ggplot2 geom_bar produces white slashes in legend keys
When I am using geom_bar I get these white slashes through the legend keys. I cannot figure out how to remove them.
ggplot(diamonds, aes(clarity, fill=cut)) + geom_bar()
I have tried using opts(legend.key = theme_blank()) but with no luck.
Any suggestions would be much appreciated.
I am using R vers. 2.15.0 and ggplot 0...
2010 Sep 10
3
ggplot bar geom: control the filling in the colour legend
Hi all,
Is it possible to change the filling of the squares used to represent
the colour legend in a bar plot with ggplot?
in this example, fillings are raven black, I'd like them white.
ggplot(diamonds, aes(clarity, colour = cut)) + geom_bar()
Regards
--
-------------
Benoit Boulinguiez
Ph.D student
Ecole de Chimie de Rennes (ENSCR) Bureau 1.20
Equipe CIP UMR CNRS 6226 "Sciences Chimiques de Rennes"
Avenue du G?n?ral Leclerc
CS 50837
35708 Rennes CEDEX 7
Tel 33 (0)2 23 23 80 83
Fax 33 (0)2 23 23 81 20
http://www.ensc-renne...
2011 Nov 16
1
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 a g...
2012 Apr 23
1
ggplot2 - geom_bar
...'product1','product2',
'product1','product2'),
value=c(1,1,1,1,
1,1,1,1))
str(molten)
molten
ggplot(molten, aes(date, weight = value, fill = channel)) +
geom_bar(colour = I('black')) + facet_grid(product ~ .)
-->8--
This gives the expected result (at least I expect this, see attachment
case1). When I change molten to:
molten <- data.frame(date=c('01','01','01','01',
'02',...
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!
[...
2011 Dec 04
1
Polishing my geom_bar for publication
...(2) removing the y-axis (species name) on the right figure to avoid duplication, and (3) fix the width, such that both figures have the same apparence regardless of the legend.
Thank you very much in advance!
The code is as follow:
(a<-ggplot(Final2, aes(x=spp, y=CPUE, fill=season)) +
geom_bar(position=position_dodge()) +
geom_errorbar(aes(ymin=CPUE-cpue.se, ymax=CPUE+cpue.se),
size=.3,
width=.2,
position=position_dodge(.9)) +
xlab("Species") + scale_x_discrete(breaks=c("100","102","107&q...
2012 Nov 30
1
Changing the base of geom_bar in ggplot
...ue from the 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.
2013 Apr 30
1
Stacked geom_bar with aggregated SE -ggplot2
...,?
? ? ? ? ? ? ? ? ? ? ? ? mean_price = mean(price),?
? ? ? ? ? ? ? ? ? ? ? ? se_price = sd(price)/sqrt(length(price))?
? ? ? ? ? ? ? ? ? ? ? ? )?
?limits <- aes(ymax = mean_price + se_price, ymin = mean_price - se_price)?
a<-ggplot(diamonds_df, aes(x = cut, y = mean_price, fill=color)) +?
?geom_bar(position=position_stack(width=0.9))?
a?
Then attempting to add error bars:?
a+ geom_errorbar(limits, position=position_stack(width=0.9), width=0.9)?
I have tried: ??
r + stat_sum_df("mean_cl_normal", geom = "errorbar"), ?using the aggregation
function in?http://www.stanford.ed...
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...
2012 Feb 01
1
ggplot2(0.9.0): could not find function "=="
...lt;- read.csv("http://pastie.org/pastes/629247/download", header = TRUE, stringsAsFactors = FALSE)
> balance <- ddply(trade, .(Time), summarise, balance = sum(EXP - IMP))
> trade.m <- melt(trade, id.vars = c("BEC", "Time"))
> ggplot(trade.m, aes(Time)) + geom_bar(subset = .(variable ==
+ "EXP"), aes(y = value, fill = BEC), stat = "identity") +
+ geom_bar(subset = .(variable == "IMP"),
+ aes(y = -value, fill = BEC), stat = "identity") +
+ xlab("") + scale_y_continuous(&qu...