[R] ggplot2-barplot

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Mon Jun 23 11:01:47 CEST 2008


Dear Felipe,

Is this what you want?

library(ggplot2)
mydata <- data.frame(PondName = factor(LETTERS[1:5]), avgWt = rnorm(5,
mean = 10, sd = 3))
ggplot(mydata, aes(x = PondName, y = avgWt)) + geom_bar()
ggplot(mydata, aes(x = PondName, y = avgWt, fill = PondName)) +
geom_bar()

HTH,

Thierry 


------------------------------------------------------------------------
----
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
Thierry.Onkelinx op inbo.be 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey

-----Oorspronkelijk bericht-----
Van: r-help-bounces op r-project.org [mailto:r-help-bounces op r-project.org]
Namens Felipe Carrillo
Verzonden: maandag 23 juni 2008 2:09
Aan: r-help op stat.math.ethz.ch
Onderwerp: [R] ggplot2-barplot


Hi all:
I have been using ggplot2 graphics for quite some time now and I really
like it. However, I haven't used barplots enough to understand the
arquitecture behind it. Can someone show me how to make this simple
barplot graph with ggplot2? I want "PondName" along the x axis and
"avgWt" along the Y axis which represents the avgWt by each Pond. 

PondName	avgWt
Pond01	21.5
Pond02	17.8
Pond03	17.8
Pond04	17.8
Pond05	16.375
Pond06	21.5
Pond07	21.5

Using sigmaplot or Excel is a simple task but I can't get it to work
with ggplot2. I was trying:

qplot(PondName,data=mydata,geom="bar") + geom_bar(fill=factor(PondName))
but I don't get the desired results. Thanks

______________________________________________
R-help op 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.



More information about the R-help mailing list