[R] lattice plot query

Dennis Murphy djmuser at gmail.com
Thu Jun 9 22:56:57 CEST 2011


Hi:

Try the following - the illustration below is for exactly one set of
panel plots. Adapt as necessary to your situation:

# Reorder the levels of subject - in this case I put them in a new variable
MyData$subj <- factor(MyData$Subj, levels = c(paste('S', 1:13, sep = '')))
xyplot(value ~ Time | subj, data = MyData, as.table = TRUE,
 layout = c(3, 4), aspect = 'xy', type = c('g', 'p', 'r'),
 drop.unused.levels=TRUE, xlab = 'Time')

as.table = TRUE starts the panel order from the upper left rather than
the lower left.

HTH,
Dennis

On Thu, Jun 9, 2011 at 4:00 AM, Vijayan Padmanabhan
<V.Padmanabhan at itc.in> wrote:
> Dear R Group
> I have the following data for which I am trying to create subject wise
> lattice plot for a given attribute and product .
> though the lattice plot is generated, for some reasons that i dont
> understand in each plot the subject panels take a random order, I would
> rather want all the plots to display the subject order in the same order
> as how i have ordered this particular factor level.
>
> Would appreciate if someone would provide me the parameter that i need to
> pass to the xyplot function of library(lattice) to get this sorted out.
>
>
> ##the data for illustrative purpose..is as follows:
>
> MyData<- structure(list(Subj = structure(c(3L, 3L, 3L, 3L, 3L, 3L, 3L,
> 3L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
> 9L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 1L, 1L, 1L, 1L, 1L,
> 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L,
> 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 7L, 7L, 7L, 7L, 7L,
> 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 11L, 11L, 11L, 11L,
> 11L, 11L, 11L, 11L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
> 2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4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 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L,
> 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L,
> 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L,
> 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L,
> 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L,
> 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L,
> 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L,
> 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L,
> 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L,
> 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L,
> 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L,
> 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L,
> 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L), .Label = c("T0",
> "T1", "T2", "T3", "T4", "T5", "T6", "T7"), class = "factor"),
>    value = c(39.5527423278832, 38.2473086972328, 40.2276345888737,
>    37.5267332387073, 40.9688951303111, 39.0569778014684,
> 39.1695786007607,
>    38.9139593338983, 68.8265651458469, 72.0887495716813,
> 67.5611670846489,
>    66.9874884774268, 66.9829433510606, 54.8956638696188,
> 63.0168969989417,
>    65.6194764863213, 66.4129384714848, 66.0961638072511,
> 68.9661166309607,
>    68.7059517735383, 65.7542747314885, 65.5069438367477,
> 64.7683246003315,
>    61.4962919814996, 69.5762947663818, 73.3430582378711,
> 76.8645584330803,
>    68.2802524581975, 77.8816834151128, 74.2317212282283,
> 70.4892680115894,
>    73.5430313565372, 45.0183417657248, 48.1530494831865,
> 46.1558267920891,
>    48.6541405845911, 48.4048804759923, 48.590343912936, 44.7362547527865,
>
>    42.6373136974049, 39.9917820318598, 43.4586441692621,
> 41.6364183563171,
>    42.8906355926352, 45.5495273145838, 41.3577962405852, 41.496338708892,
>
>    40.0151968165421, 45.5648864982887, 46.2956996070121,
> 47.0280057728853,
>    50.1831679877159, 51.061682921112, 45.9831040407059, 44.9747480866787,
>
>    49.6665131229635, 54.8281039296233, 54.1930629171256,
> 54.4341268439816,
>    57.1044051058105, 56.1143459282325, 52.6161245346639,
> 52.7130458240943,
>    55.4358255649899, 47.2220107045472, 47.3389267304398,
> 46.2106468232384,
>    48.9990363616358, 46.8056280265232, 46.5981260727775,
> 46.4927574552312,
>    40.3333491167334, 62.2287823821622, 66.3810749127077,
> 67.2394807083061,
>    62.4429875125554, 69.0376706648671, 60.2812609331127, 61.455201318328,
>
>    59.9863854008917, 62.2997182356239, 68.3165884503308,
> 70.8613200740368,
>    75.5343092931554, 68.0613856491741, 67.8297794393095, 69.723445715177,
>
>    68.2294718401127, 52.8140766072603, 51.4240493093108,
> 49.1567458446157,
>    52.7574433410593, 51.8096008153661, 51.0542236981057,
> 49.1650793229206,
>    46.1961387381546, 39.3501757447082, 40.6370147384917,
> 42.6126353906914,
>    42.8371247270351, 45.6224375518759, 38.1946693028616,
> 42.6841902106385,
>    41.2891110860076, 46.5589402020299, 46.9236938185125,
> 46.7985819317017,
>    52.9563382730808, 52.7678198507564, 42.6784974818896,
> 46.0254807534733,
>    49.3617924018815, 55.0347336430881, 53.0553009508891,
> 59.1754785059011,
>    59.2551361838499, 58.7606127906148, 56.0068865579661,
> 59.7877691476509,
>    59.9894635155904, 45.8292743149289, 44.3975346123602,
> 44.0878763837905,
>    43.0034203212678, 44.7694956749990, 44.5206026642237,
> 44.1129676323369,
>    41.1441655434737, 64.502950186561, 66.2596818647181, 66.9718770730599,
>
>    68.3492812036726, 71.1329167451021, 60.993158766883, 64.0476800619917,
>
>    59.5722548586232, 69.1060115847223, 68.8225246639702,
> 71.3984976174081,
>    80.9630180588849, 73.007714590984, 65.7790674687866, 68.8673355306755,
>
>    66.8813383526656, 40.0423309528637, 44.1216443512537,
> 41.9734395557559,
>    44.8434380300801, 43.7494322571724, 43.3183356186337,
> 45.5420445201619,
>    42.5147260103379, 68.7745002341477, 61.981198669435, 61.7864827933066,
>
>    60.3458594826638, 59.9697661699882, 53.9643718467014,
> 59.1755018103991,
>    59.2276568453173, 62.7915792989106, 71.0620731987689,
> 72.2036228167234,
>    70.9247270575656, 67.1627603989188, 69.8883404495198,
> 63.0049593358823,
>    64.8912785345249, 68.8781924408982, 74.137601748426, 75.2732261184303,
>
>    71.669750963672, 74.4341280041274, 76.2382402210529, 69.7026459277572,
>
>    76.5074726515534, 29.2874363361783, 27.2892266662294,
> 29.5616488492521,
>    29.6852458522043, 30.5496200171305, 29.9966252445121,
> 29.1288540248101,
>    27.4806129668759, 33.5863501946243, 30.4931479044075,
> 29.5862807824957,
>    34.9382017751209, 35.238424232798, 29.4052475587535, 33.0798423075101,
>
>    31.3567180682194, 33.4690209827123, 30.6523035293150,
> 32.6208075805269,
>    33.9407265800815, 31.0650808724465, 36.7534951846668,
> 34.6967011594745,
>    31.9567044598027, 44.5158738295474, 40.4690204233383,
> 38.0597778223743,
>    37.8034937870776, 35.1720350896499, 39.8550085954103,
> 34.9099191361032,
>    42.0149439902365, 26.2151235666232, 23.5679852219729,
> 24.2001786793751,
>    23.6961503280406, 23.7185784815809, 25.3066274885425,
> 24.0292003617619,
>    24.2505451653069, 27.0291768503551, 27.9586095806653,
> 27.1539912074178,
>    27.3800648825246, 27.0086310697033, 29.5006091073482,
> 27.6618986740352,
>    26.6054039275563, 26.7544589952818, 25.7739723955002,
> 24.7493173361881,
>    24.8974539247832, 26.0066344196213, 25.7242948862424,
> 24.2129429825322,
>    26.2810081950791, 32.8501876144134, 27.2087875772192,
> 22.9241752520302,
>    23.9219026236064, 27.8607929641585, 27.7779664335406,
> 25.6974359198254,
>    26.0076906518561, 28.8549852933942, 27.2116802644414,
> 28.5718875220588,
>    30.5721859479267, 29.2724683799154, 29.7833383429998,
> 29.0348479362964,
>    27.1223342602551, 32.5582746876519, 28.4460181623792,
> 30.5181241094846,
>    27.8313626195291, 36.6535660010998, 31.2270378533636,
> 30.7505338399547,
>    28.3032529970344, 32.3568559611009, 34.9553492819238,
> 35.7759456755808,
>    36.0195354653364, 38.5285002594439, 35.7380230921731,
> 37.1484588196843,
>    38.5416308644471, 24.8506692697752, 24.6343520347229,
> 23.6083195613371,
>    24.7607264684248, 22.9854229667107, 23.9036751221927,
> 24.0387963674900,
>    22.7723194255264, 30.3793074740804, 28.8639832951117,
> 28.3030690013896,
>    27.8655679757535, 29.1997887609265, 30.1487803931287,
> 29.2987532171346,
>    28.5871764431944, 24.6444755508312, 24.7330180273872,
> 23.7338446480537,
>    25.8596684061866, 26.0787857361113, 24.8953653206929,
> 23.5625674439808,
>    24.479442599818, 29.6545075345955, 25.6090083380698, 27.1114528433399,
>
>    29.5090563448938, 31.455338578686, 31.5408279032055, 32.0051421579701,
>
>    33.4618122321904, 27.4889692245983, 25.5464291578372,
> 24.5476688346391,
>    25.2081446883923, 26.3672783411296, 25.6265928833026,
> 27.1950139669246,
>    27.130001618485, 28.6347421265670, 26.7649268696797, 28.0626929191564,
>
>    30.4520327581967, 30.4717296368313, 29.8812011276167,
> 30.4064647569007,
>    30.7831770362286, 37.7827415537242, 35.0879233395691,
> 34.7668091883955,
>    37.3427148382295, 38.3775395012458, 36.7485828173724, 38.193636145425,
>
>    34.5786595343394, 28.6171348871096, 27.9470627780942,
> 29.8327633149340,
>    29.6097653173267, 30.0836756702669, 31.0359954571051,
> 31.0662062327447,
>    28.8585430558031, 29.7252130104938, 26.5553131151419,
> 28.0655400327958,
>    28.7575356242266, 28.3515991163835, 26.4610318654439,
> 27.2362207214083,
>    28.0005735091048, 29.1041755824943, 29.5347668690827,
> 32.1870020976934,
>    31.1451531051784, 25.2860128452551, 29.1578475612553,
> 27.0033058437616,
>    24.4368356738120, 39.7697712026109, 35.1675811365275,
> 32.1336514906396,
>    35.5524206935849, 33.5035236183325, 34.2439798004073,
> 33.6508805746601,
>    33.8661875340464)), .Names = c("Subj", "Product", "Arm",
> "Attribute", "Time", "value"), row.names = c(NA, 352L), class =
> "data.frame")
>
>
> ## Here is the code to create lattice plot subject wise, for each
> attribute and product from the study..
> ##This code creates a pdf file output of all plots and saves the file in
> the destination given.
>
> library(lattice)
> Attributeindata<-levels(MyData$Attribute)
> productindata<-levels(MyData$Product)
> pdf(file="D:/Test/latticeplotsbysubject.pdf")
> for(i in 1:length(Attributeindata))
> {
>        for(j in 1:length(productindata))
>        {
> print(xyplot(value ~ Time | Subj,
> data=subset(MyData,Attribute==Attributeindata[i] & Product=="b"),layout =
> c(6,3), aspect = "xy",, type = c("g", "p",
> "r"),drop.unused.levels=TRUE,index.cond = function(x,y) coef(lm(y ~
> x))[1],ylab = paste("value of",Attributeindata[i],"for
> Product",productindata[j]),
>             xlab = "Time",))
>             }
> }
>
>
> ##On examining the pdf file, you wil find that the order of subjects as
> appearing in each page of plot is different.
> ## I would want the order of subjects to appear in the same order as
> ##follows: "S1","S3","S4","S5","S6","S8","S9","S10","S11", "S12","S13"
> ##I have tried reorder function on the factor level "Subj" but it does not
> give the desired result.
>
> Any help in modifying the code above to meet the requirement would be
> highly appreciated.
>
> Thanks & Regards
> Vijayan Padmanabhan
>
>
> "What is expressed without proof can be denied without proof" - Euclide.
>
> Please visit us at www.itcportal.com
> ******************************************************************************
> This Communication is for the exclusive use of the intended recipient (s) and shall
> not attach any liability on the originator or ITC Ltd./its Subsidiaries/its Group
> Companies. If you are the addressee, the contents of this email are intended for your use only and it shall not be forwarded to any third party, without first obtaining written authorisation from the originator or ITC Ltd./its Subsidiaries/its Group Companies. It may contain information which is confidential and legally privileged and the same shall not be used or dealt with by any third party in any manner whatsoever without the specific consent of ITC Ltd./its Subsidiaries/its Group Companies.
>        [[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.
>



More information about the R-help mailing list