Hi All, I am new at R so any help would be appreciate. Below my current R-code/script: initial.dir<-getwd() setwd('/Users/jurgens/VirtualEnv/venv/Projects/QTLS/Resaved_Results') dataset <- read.table("LWxANNA_FinalReport_resaved_spwc.csv", header=TRUE, sep="\t" ) n <- length(dataset$X..No.Call) x <- sort(dataset$X..No.Call,partial = n )[n] outlier <- dataset[ dataset$X..No.Call > quantile(dataset$X..No.Call,0.25) + (IQR(dataset$X..No.Call) *1.5),] par( las=2, cex.axis=0.5, cex.lab=1, cex.main=2, cex.sub=1) barplot(dataset$X..No.Call, names.arg = dataset$Individual.Sample, cex.names=0.5 ,space=0.5, ylim=c(0,x*1.5) ) setwd(initial.dir) I would like to highlight the sample in outlier on the barplot that is create, would this be possible? Thanks -- Regards/Groete/Mit freundlichen Grüßen/recuerdos/meilleures salutations/ distinti saluti/siong/duì yú/привет Jurgens de Bruin [[alternative HTML version deleted]]
It's a bit difficult to know what you are doing without any data. Would you supply some data please. See ?dput for the easiest way to supply it. Also have a look at https://github.com/hadley/devtools/wiki/Reproducibility and/or http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example for some suggetions on asking questions and code formatting. John Kane Kingston ON Canada> -----Original Message----- > From: debruinjj at gmail.com > Sent: Wed, 31 Jul 2013 16:57:55 +0200 > To: r-help at r-project.org > Subject: [R] Highlight selected bar in barplot > > Hi All, > > I am new at R so any help would be appreciate. > > Below my current R-code/script: > > initial.dir<-getwd() > setwd('/Users/jurgens/VirtualEnv/venv/Projects/QTLS/Resaved_Results') > dataset <- read.table("LWxANNA_FinalReport_resaved_spwc.csv", > header=TRUE, > sep="\t" ) > n <- length(dataset$X..No.Call) > x <- sort(dataset$X..No.Call,partial = n )[n] > > outlier <- dataset[ dataset$X..No.Call > > quantile(dataset$X..No.Call,0.25) > + (IQR(dataset$X..No.Call) *1.5),] > > par( las=2, cex.axis=0.5, cex.lab=1, cex.main=2, cex.sub=1) > barplot(dataset$X..No.Call, names.arg = dataset$Individual.Sample, > cex.names=0.5 ,space=0.5, ylim=c(0,x*1.5) ) > setwd(initial.dir) > > I would like to highlight the sample in outlier on the barplot that is > create, would this be possible? > > > Thanks > -- > Regards/Groete/Mit freundlichen GrC<C?en/recuerdos/meilleures > salutations/ > distinti saluti/siong/duC, yC:/P?Q?P8P2P5Q? > > Jurgens de Bruin > > [[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 MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!
On 08/01/2013 12:57 AM, Jurgens de Bruin wrote:> Hi All, > > I am new at R so any help would be appreciate. > > Below my current R-code/script: > > initial.dir<-getwd() > setwd('/Users/jurgens/VirtualEnv/venv/Projects/QTLS/Resaved_Results') > dataset<- read.table("LWxANNA_FinalReport_resaved_spwc.csv", header=TRUE, > sep="\t" ) > n<- length(dataset$X..No.Call) > x<- sort(dataset$X..No.Call,partial = n )[n] > > outlier<- dataset[ dataset$X..No.Call> quantile(dataset$X..No.Call,0.25) > + (IQR(dataset$X..No.Call) *1.5),] > > par( las=2, cex.axis=0.5, cex.lab=1, cex.main=2, cex.sub=1) > barplot(dataset$X..No.Call, names.arg = dataset$Individual.Sample, > cex.names=0.5 ,space=0.5, ylim=c(0,x*1.5) ) > setwd(initial.dir) > > I would like to highlight the sample in outlier on the barplot that is > create, would this be possible? >Hi Jurgens, Even without the data, I think that what you mean by "highlight" is the major point of confusion. If you have five bars in the resulting barplot and the third one is the one you want to highlight, you could do this: barplot(...,col=c(NA,NA,"red",NA,NA),...) You would then have four empty bars and one "highlighted" in red. You could put an asterisk in the center of the third bar: barpos<-barplot(...) text(barpos[3],dataset$X..No.Call[3]/2,"*") Just depends upon how you want to highlight the bar in question. Jim
You may be interested in the iplots package. It has methods where you can create multiple plots and select a point or points in one plot and they will be highlighted on the other plots. On Wed, Jul 31, 2013 at 8:57 AM, Jurgens de Bruin <debruinjj@gmail.com>wrote:> Hi All, > > I am new at R so any help would be appreciate. > > Below my current R-code/script: > > initial.dir<-getwd() > setwd('/Users/jurgens/VirtualEnv/venv/Projects/QTLS/Resaved_Results') > dataset <- read.table("LWxANNA_FinalReport_resaved_spwc.csv", header=TRUE, > sep="\t" ) > n <- length(dataset$X..No.Call) > x <- sort(dataset$X..No.Call,partial = n )[n] > > outlier <- dataset[ dataset$X..No.Call > quantile(dataset$X..No.Call,0.25) > + (IQR(dataset$X..No.Call) *1.5),] > > par( las=2, cex.axis=0.5, cex.lab=1, cex.main=2, cex.sub=1) > barplot(dataset$X..No.Call, names.arg = dataset$Individual.Sample, > cex.names=0.5 ,space=0.5, ylim=c(0,x*1.5) ) > setwd(initial.dir) > > I would like to highlight the sample in outlier on the barplot that is > create, would this be possible? > > > Thanks > -- > Regards/Groete/Mit freundlichen Grüßen/recuerdos/meilleures salutations/ > distinti saluti/siong/duì yú/привет > > Jurgens de Bruin > > [[alternative HTML version deleted]] > > > ______________________________________________ > R-help@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. > >-- Gregory (Greg) L. Snow Ph.D. 538280@gmail.com [[alternative HTML version deleted]]
---------- Forwarded message ---------- From: Jurgens de Bruin <debruinjj at gmail.com> Date: 2 August 2013 08:51 Subject: Re: [R] Highlight selected bar in barplot To: Greg Snow <538280 at gmail.com> Hi, Apologies for the late reply... Attached is a dataset. Hope this help. So I draw a barplot based on the dataset. Then using the following: outlier <- dataset[ dataset$X..No.Call > quantile(dataset$X..No.Call,0.25) + (IQR(dataset$X..No.Call) *1.5),] to identify samples/bars that I would like to color a different color than the rest. Thanks gain On 1 August 2013 18:05, Greg Snow <538280 at gmail.com> wrote:> You may be interested in the iplots package. It has methods where you can > create multiple plots and select a point or points in one plot and they > will be highlighted on the other plots. > > > On Wed, Jul 31, 2013 at 8:57 AM, Jurgens de Bruin <debruinjj at gmail.com>wrote: > >> Hi All, >> >> I am new at R so any help would be appreciate. >> >> Below my current R-code/script: >> >> initial.dir<-getwd() >> setwd('/Users/jurgens/VirtualEnv/venv/Projects/QTLS/Resaved_Results') >> dataset <- read.table("LWxANNA_FinalReport_resaved_spwc.csv", header=TRUE, >> sep="\t" ) >> n <- length(dataset$X..No.Call) >> x <- sort(dataset$X..No.Call,partial = n )[n] >> >> outlier <- dataset[ dataset$X..No.Call > quantile(dataset$X..No.Call,0.25) >> + (IQR(dataset$X..No.Call) *1.5),] >> >> par( las=2, cex.axis=0.5, cex.lab=1, cex.main=2, cex.sub=1) >> barplot(dataset$X..No.Call, names.arg = dataset$Individual.Sample, >> cex.names=0.5 ,space=0.5, ylim=c(0,x*1.5) ) >> setwd(initial.dir) >> >> I would like to highlight the sample in outlier on the barplot that is >> create, would this be possible? >> >> >> Thanks >> -- >> Regards/Groete/Mit freundlichen Gr??en/recuerdos/meilleures salutations/ >> distinti saluti/siong/du? y?/?????? >> >> Jurgens de Bruin >> >> [[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. >> >> > > > -- > Gregory (Greg) L. Snow Ph.D. > 538280 at gmail.com >-- Regards/Groete/Mit freundlichen Gr??en/recuerdos/meilleures salutations/ distinti saluti/siong/du? y?/?????? Jurgens de Bruin -- Regards/Groete/Mit freundlichen Gr??en/recuerdos/meilleures salutations/ distinti saluti/siong/du? y?/?????? Jurgens de Bruin