David Afshartous
2007-Oct-12 15:31 UTC
[R] Basic plot question: Figure 1.1 Pinheiro & Bates
All, Sorry for overly simplistic question, but I can't seem to remember how to create the basic plot shown in Figure 1.1 of Pinheiro & Bates (2004; p.4). The y-axis delineates a factor (Rail) while the x-axis displays the distribution of a continuous variable (time) according to each level of the factor. Didn't see it in archives but perhaps I'm not searching on correct key words, any help appreciated, David> library("nlme") > RailGrouped Data: travel ~ 1 | Rail Rail travel 1 1 55 2 1 53 3 1 54 4 2 26 5 2 37 6 2 32 7 3 78 8 3 91 9 3 85 10 4 92 11 4 100 12 4 96 13 5 49 14 5 51 15 5 50 16 6 80 17 6 85 18 6 83
On Friday 12 October 2007 17:31:22 David Afshartous wrote: DA > All, DA > Sorry for overly simplistic question, but I can't seem to remember how to DA > create the basic plot shown in Figure 1.1 of Pinheiro & Bates (2004; p.4). DA > The y-axis delineates a factor (Rail) while the x-axis displays the DA > distribution of a continuous variable (time) according to each level of the DA > factor. Didn't see it in archives but perhaps I'm not searching on correct DA > key words, any help appreciated, DA > David library(lattice) xyplot(Rail~travel,data=Rail) -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part. Url : https://stat.ethz.ch/pipermail/r-help/attachments/20071012/75ffbe83/attachment.bin
On 10/12/07, David Afshartous <dafshartous at med.miami.edu> wrote:> All, > Sorry for overly simplistic question, but I can't seem to remember how to > create the basic plot shown in Figure 1.1 of Pinheiro & Bates (2004; p.4). > The y-axis delineates a factor (Rail) while the x-axis displays the > distribution of a continuous variable (time) according to each level of the > factor. Didn't see it in archives but perhaps I'm not searching on correct > key words, any help appreciated, > David> > library("nlme") > > Rail > Grouped Data: travel ~ 1 | Rail > Rail travel > 1 1 55 > 2 1 53 > 3 1 54 > 4 2 26 > 5 2 37 > 6 2 32 > 7 3 78 > 8 3 91 > 9 3 85 > 10 4 92 > 11 4 100 > 12 4 96 > 13 5 49 > 14 5 51 > 15 5 50 > 16 6 80 > 17 6 85 > 18 6 83That plot can be reproduced by> library(lattice) > data(Rail, package = "nlme") > dotplot(Rail ~ travel, Rail)However, this relies on the Rail$Rail factor being ordered by increasing mean travel time, which is fine for the plot but may get in the way of other uses of the data. In a way we only want to assign an order to the levels of the Rail factor for the purposes of the plot. As Deepayan Sarkar mentions in his useR!2007 presentation (http://user2007.org/program/presentations/sarkar.pd) he has done a considerable amount of upgrading of the lattice package, relative to the original design of Trellis graphics, in part to make the nlme plots easier to create. The version of the Rail data in the MEMSS package removes the ordering on the levels of the Rail factor so it defaults to the original order. Compare> data(Rail, package = "MEMSS") > dotplot(Rail ~ travel, Rail) > dotplot(reorder(Rail, travel) ~ travel, Rail)The latter plot is the way I would recommend constructing that plot now.
Reasonably Related Threads
- on trellis.par.set/get (reproducing figures from Pinheiro & Bates)
- Pinheiro/Bates Soybean nlme failure
- wroung groupedData despite reading Bates and Pinheiro 3 times
- Question about mixed-effects models example (Pinheiro and Bates)
- "symbol print-name too long"