[R] How to use ggplot2
John Kane
jrkrideau at inbox.com
Wed Nov 26 18:42:19 CET 2014
It is useful to have a reproducable example
https://github.com/hadley/devtools/wiki/Reproducibility
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
However is this somethingl like what you want? Note I changed variable names and removed caps to make life easier and renamed the dataset to dat1 (just handier for me). I think "col" as a reserved word should not be used. It seemed to be causing a problem.
library(ggplot2)
dat1 <- structure(list(aa = 189:194, bb = c(158L, 54272L, 301574L, 161620L,
61263L, 83800L), colmat = c(158L, 54272L, 301574L, 161620L, 61263L,
83800L), fastq = c(158L, 54272L, 301574L, 161620L, 61263L, 83800L
), miseq = c(104L, 32122L, 152625L, 100469L, 38109L, 40095L)), .Names = c("aa",
"bb", "colmat", "fastq", "miseq"), class = "data.frame", row.names = c(NA,
-6L))
p1 <- ggplot(dat1, aes( as.factor(aa), y = bb, fill = as.factor(aa)))
p1 <- p1 + geom_bar(stat = "identity")
p1
John Kane
Kingston ON Canada
> -----Original Message-----
> From: jarod_v6 at libero.it
> Sent: Wed, 26 Nov 2014 18:04:21 +0100 (CET)
> To: r-help at r-project.org
> Subject: [R] How to use ggplot2
>
> Dear All!!
> I'll try to plot a barplot using aggplot2
>
> head(alt)
> as.factor.data...7.. Col ColMat Fastq miseq
> 1 189 158 158 158 104
> 2 190 54272 54272 54272 32122
> 3 191 301574 301574 301574 152625
> 4 192 161620 161620 161620 100469
> 5 193 61263 61263 61263 38109
> 6 194 83800 83800 83800 40095
>>
> p<- ggplot(data = alt, aes(y = alt[,2])) + geom_bar()
>
> Error : Mapping a variable to y and also using stat="bin".
> With stat="bin", it will attempt to set the y value to the count of
> cases in each group.
> This can result in unexpected behavior and will not be allowed in a
> future version of ggplot2.
> If you want y to represent counts of cases, use stat="bin" and don't
> map a variable to y.
> If you want y to represent values in the data, use stat="identity".
> See ?geom_bar for examples. (Defunct; last used in version 0.9.2)
> How can resolve this problem?
> My data are in column: each columns are conditions and each row rappresnt
> a sample
> thanks for your help!
> M
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
More information about the R-help
mailing list