An embedded and charset-unspecified text was scrubbed... Name: inte tillg?nglig Url: https://stat.ethz.ch/pipermail/r-help/attachments/20070103/d0f3260e/attachment.pl
This should do it. You can play around with the alignment of the labels. input <- ' ID index lb 100 FLINDYTHNIPLI 1.84770221 9.087463 101 none 0.06657547 8.927778 102 GDDKVYSANGFTT -0.22922544 8.599913 103 GDFTQGPQSAKTR 0.01203925 8.483816 104 GDKEFSDALGYLQ -0.06264494 8.463524 105 GDPTETLRQCFDD -0.10011148 8.483816 106 GDSGGSFQNGHAQ -0.13460447 8.442943 107 GDVYSFAIIMQEV 1.91504700 8.413628 108 GLRSLYPPPPPPQ -0.11224126 8.383704 109 GLWVTYKAQDAKT 0.03723291 8.257388 110 GMSQPLLDRTVPD -0.06580206 8.294621 ' # read in the data inData <- read.table(textConnection(input), header=TRUE) with(inData, { plot(lb,index, pch=1, col=5,cex=1, lwd=2, xlab="LB", ylab="Index",cex.main =1,font.main= 1, main="scatterplot") text(lb[index > 1.5], index[index > 1.5], labels=ID[index > 1.5]) # label the outliers }) On 1/3/07, Jenny persson <jenny197806@yahoo.se> wrote:> > Dear R-users, > > I have following data > > > # Plot coloured scatter plot > > c<-dat[100:110,c(5,7,8)] > > par(mfrow=c(3,2)) > plot(c$lb,c$index, pch=1, col=5,cex=1, lwd=2, > xlab="LB", ylab="Index",cex.main =1,font.main= 1, > main="scatterplot") > > ID index lb > 100 FLINDYTHNIPLI 1.84770221 9.087463 > 101 none 0.06657547 8.927778 > 102 GDDKVYSANGFTT -0.22922544 8.599913 > 103 GDFTQGPQSAKTR 0.01203925 8.483816 > 104 GDKEFSDALGYLQ -0.06264494 8.463524 > 105 GDPTETLRQCFDD -0.10011148 8.483816 > 106 GDSGGSFQNGHAQ -0.13460447 8.442943 > 107 GDVYSFAIIMQEV 1.91504700 8.413628 > 108 GLRSLYPPPPPPQ -0.11224126 8.383704 > 109 GLWVTYKAQDAKT 0.03723291 8.257388 > 110 GMSQPLLDRTVPD -0.06580206 8.294621 > > When I plotted a scatter plot of index against lb, there are two extreme > values. How can I plot so that these values are replaced by their ID or the > IDs are next to these values on the graph? I want to do something like: if > index > 1.5 then plot the IDs instead of the indexes greater than 1.5 or > place the Ids next to their indexes. > The data above is a little part of my real data (which might have more > than two extreme outliers). > > Thanks for your help, > > Jenny > > __________________________________________________ > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@stat.math.ethz.ch 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]]
Hi On 3 Jan 2007 at 12:54, Jenny persson wrote: Date sent: Wed, 3 Jan 2007 12:54:50 +0100 (CET) From: Jenny persson <jenny197806 at yahoo.se> To: r-help at stat.math.ethz.ch Subject: [R] How to add characters on graph ?> Dear R-users, > > I have following data > > > # Plot coloured scatter plot > > c<-dat[100:110,c(5,7,8)] > > par(mfrow=c(3,2)) > plot(c$lb,c$index, pch=1, col=5,cex=1, lwd=2, > xlab="LB", ylab="Index",cex.main =1,font.main= 1, > main="scatterplot") > > ID index lb > 100 FLINDYTHNIPLI 1.84770221 9.087463 > 101 none 0.06657547 8.927778 > 102 GDDKVYSANGFTT -0.22922544 8.599913 > 103 GDFTQGPQSAKTR 0.01203925 8.483816 > 104 GDKEFSDALGYLQ -0.06264494 8.463524 > 105 GDPTETLRQCFDD -0.10011148 8.483816 > 106 GDSGGSFQNGHAQ -0.13460447 8.442943 > 107 GDVYSFAIIMQEV 1.91504700 8.413628 > 108 GLRSLYPPPPPPQ -0.11224126 8.383704 > 109 GLWVTYKAQDAKT 0.03723291 8.257388 > 110 GMSQPLLDRTVPD -0.06580206 8.294621 > > When I plotted a scatter plot of index against lb, there are two > extreme values. How can I plot so that these values are replaced by > their ID or the IDs are next to these values on the graph? I want to > do something like: if index > 1.5 then plot the IDs instead of the > indexes greater than 1.5 or place the Ids next to their indexes. TheI would use such construction plot(x,y, ..., type="n") points(x,y, pch=c(NA,1)[(index>1.5)+1]) sel<-(index>1.5) text(x[sel],y[sel], ID[sel]) see ?points, ?text, ?plot HTH Petr> data above is a little part of my real data (which might have more > than two extreme outliers). > > Thanks for your help, > > Jenny > > __________________________________________________ > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch 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.Petr Pikal petr.pikal at precheza.cz
If you just want to label and identify outliers after creating a plot then look at the identify function. In your case you could just run the following command after creating your plot:> out.index <- identify( c$lb, c$index )Then click on (or near) the outliers or other interesting points. The points will be labelled on the plot and their position in the dataset will be saved in out.index. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at intermountainmail.org (801) 408-8111> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Jenny persson > Sent: Wednesday, January 03, 2007 4:55 AM > To: r-help at stat.math.ethz.ch > Subject: [R] How to add characters on graph ? > > Dear R-users, > > I have following data > > > # Plot coloured scatter plot > > c<-dat[100:110,c(5,7,8)] > > par(mfrow=c(3,2)) > plot(c$lb,c$index, pch=1, col=5,cex=1, lwd=2, > xlab="LB", ylab="Index",cex.main =1,font.main= 1, > main="scatterplot") > > ID index lb > 100 FLINDYTHNIPLI 1.84770221 9.087463 > 101 none 0.06657547 8.927778 > 102 GDDKVYSANGFTT -0.22922544 8.599913 > 103 GDFTQGPQSAKTR 0.01203925 8.483816 > 104 GDKEFSDALGYLQ -0.06264494 8.463524 > 105 GDPTETLRQCFDD -0.10011148 8.483816 > 106 GDSGGSFQNGHAQ -0.13460447 8.442943 > 107 GDVYSFAIIMQEV 1.91504700 8.413628 > 108 GLRSLYPPPPPPQ -0.11224126 8.383704 > 109 GLWVTYKAQDAKT 0.03723291 8.257388 > 110 GMSQPLLDRTVPD -0.06580206 8.294621 > > When I plotted a scatter plot of index against lb, there > are two extreme values. How can I plot so that these values > are replaced by their ID or the IDs are next to these values > on the graph? I want to do something like: if index > 1.5 > then plot the IDs instead of the indexes greater than 1.5 or > place the Ids next to their indexes. > The data above is a little part of my real data (which > might have more than two extreme outliers). > > Thanks for your help, > > Jenny > > __________________________________________________ > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >