David Afshartous
2008-Feb-28 21:15 UTC
[R] Replacing plot symbols w/ subject IDs in xyplot()
All, How does one replace plot symbols with say subject IDs when using xyplot? Or superimpose them next to plot symbols? I searched the archives under various key words but haven't had much. Any suggestions or links much appreciated. Sample code below. David junk.frm = data.frame(ID = rep(1:16, each = 2), x, y, z = rep(c("D", "P"), 16)) y = c( 0.4, 0.6, -0.1, 0.3, 0.3, -0.2, 0.7, 0.7, 0.2, 0.0, 0.9, -0.1, 0.6, -1.1, 0.8, -1.0, 0.4, 0.1, 0.7, -0.2, -0.1, -0.1, 2.2, 0.7, 1.1, 0.2, -0.2, -0.9, 0.4, 0.1, -0.3, -0.4) x = c(4.1000, 4.9600, 1.2000, 3.9000, 3.1875, 1.9000, 1.8625, 0.7650, 1.5750, 2.4700, 1.6250, 1.5500, 2.3125, 1.3125, 1.0600, -0.5500, 1.1000, 0.0200, -0.0375, 3.4600, 2.5250, 2.0950, 0.8000, 1.6050, -0.4150, -0.7300, 1.1550, 1.4850, 2.2000, 2.2500, 0.6000, 2.1000) xyplot(y ~ x , data = junk.frm[junk.frm$z =="D",], type = c("g", "p", "smooth"), pch = 20)
Deepayan Sarkar
2008-Feb-28 23:32 UTC
[R] Replacing plot symbols w/ subject IDs in xyplot()
On 2/28/08, David Afshartous <dafshartous at med.miami.edu> wrote:> > > All, > > How does one replace plot symbols with say subject IDs when using xyplot? Or > superimpose them next to plot symbols? I searched the archives under > various key words but haven't had much. Any suggestions or links much > appreciated. Sample code below.demo("lattice") has an example. -Deepayan
David Afshartous
2008-Feb-29 15:17 UTC
[R] Replacing plot symbols w/ subject IDs in xyplot()
For plot(): plot(x,y, type = "n") text(x,y, lab= junk.frm$ID) This accomplishes the goal of using subject IDs as plot symbols, but I can't seem to get the same result below w/ xyplot(). Is there something different I have to do for xyplot()? xyplot(y ~ x, type = "n") text(x,y , lab=junk.frm$ID) # doesn't work On 2/28/08 5:09 PM, "Bert Gunter" <gunter.berton at gene.com> wrote:> ?text > > e.g > > plot(x,y,type="n") ## > text(x,y,lab= whatever) > > This replaces the plot symbols with the ID's. If you just wish to plot them > next, remove the type="n" specification and just offset the x's in text a > hair. > > -- Bert Gunter > Genentech > > > -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On > Behalf Of David Afshartous > Sent: Thursday, February 28, 2008 1:15 PM > To: r-help at r-project.org > Subject: [R] Replacing plot symbols w/ subject IDs in xyplot() > > > > All, > > How does one replace plot symbols with say subject IDs when using xyplot? Or > superimpose them next to plot symbols? I searched the archives under > various key words but haven't had much. Any suggestions or links much > appreciated. Sample code below. > > David > > > > > > junk.frm = data.frame(ID = rep(1:16, each = 2), x, y, z = rep(c("D", "P"), > 16)) > y = c( 0.4, 0.6, -0.1, 0.3, 0.3, -0.2, 0.7, 0.7, 0.2, 0.0, 0.9, > -0.1, 0.6, -1.1, 0.8, -1.0, 0.4, 0.1, 0.7, -0.2, -0.1, -0.1, 2.2, > 0.7, 1.1, 0.2, -0.2, -0.9, 0.4, 0.1, -0.3, -0.4) > x = c(4.1000, 4.9600, 1.2000, 3.9000, 3.1875, 1.9000, 1.8625, > 0.7650, 1.5750, 2.4700, 1.6250, 1.5500, 2.3125, 1.3125, 1.0600, > -0.5500, 1.1000, 0.0200, -0.0375, 3.4600, 2.5250, 2.0950, 0.8000, > 1.6050, -0.4150, -0.7300, 1.1550, 1.4850, 2.2000, 2.2500, 0.6000, > 2.1000) > xyplot(y ~ x , data = junk.frm[junk.frm$z =="D",], type = c("g", "p", > "smooth"), pch = 20) > > ______________________________________________ > 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. > >