[R] Plotting symbols and colors based upon data values

Brian Diggs diggsb at ohsu.edu
Mon Mar 14 20:16:43 CET 2011


On 3/13/2011 6:46 PM, David Winsemius wrote:
>
> On Mar 13, 2011, at 8:51 PM, Mark Linderman wrote:
>
>> David, thank you for your quick reply. I spent a few minutes getting your
>> command to work with some sparse synthetic data, and then spent several
>> hours trying to figure out why my data didn't work (at least for symbols,
>> colors look okay). I have massaged my data to where it is practically
>> indistinguishable from the synthetic data - yet it still doesn't work.
>> Attached are the two data files that can be plotted as follows:
>>
>> broken = read.table("broken.table",header=TRUE)
>> works = read.table("works.table",header=TRUE)
>> xyplot(Y ~ X | A, data=works, pch=works$C , col=works$B)
>> xyplot(Y ~ X | A, data=broken, pch=broken$C , col=broken$B)
>
> I get the same problem and after experimenting for a while I think I can
> solve it by randomizing the order of the entries:
>
>  > broken <- broken[sample(417), ]
>
>  > xyplot(Y ~ X | A, data=broken, pch=broken$C, col=broken$B)
>
> Why xyplot should fail to properly assign pch values just because all
> "1"'s are at the beginning seems to me to be a bug.
>

Using a completely different approach (ggplot2 versus lattice) and 
David's dput output for the data.frame "broken", this can be done with:

broken <- structure(list(rown = c(91L, 193L, 128L, 8L, 143L, 46L, 60L,
99L, 112L, 67L, 25L, 15L, 188L, 93L, 115L, 4L, 190L, 64L, 147L,
119L, 82L, 120L, 23L, 139L, 28L, 42L, 180L, 24L, 145L, 71L, 13L,
95L, 94L, 104L, 149L, 74L, 32L, 184L, 11L, 114L, 90L, 70L, 63L,
141L, 192L, 126L, 153L, 172L, 26L, 151L, 109L, 133L, 79L, 35L,
61L, 43L, 52L, 29L, 30L, 80L, 154L, 7L, 121L, 122L, 106L, 182L,
16L, 2L, 175L, 34L, 102L, 174L, 117L, 178L, 100L, 68L, 48L, 31L,
53L, 168L, 59L, 165L, 123L, 69L, 55L, 62L, 163L, 39L, 108L, 96L,
97L, 113L, 87L, 164L, 169L, 33L, 118L, 45L, 148L, 129L, 22L,
116L, 101L, 157L, 191L, 89L, 75L, 156L, 137L, 183L, 98L, 150L,
124L, 144L, 127L, 155L, 57L, 36L, 14L, 161L, 187L, 138L, 111L,
146L, 20L, 107L, 140L, 110L, 125L, 41L, 105L, 159L, 103L, 132L,
44L, 166L, 56L, 171L, 195L, 40L, 135L, 5L, 58L, 37L, 54L, 83L,
17L, 142L, 77L, 162L, 170L, 160L, 78L, 38L, 194L, 21L, 167L,
27L, 81L, 185L, 47L, 66L, 73L, 3L, 134L, 158L, 51L, 173L, 50L,
18L, 12L, 6L, 189L, 72L, 85L, 65L, 92L, 179L, 86L, 49L, 130L,
177L, 152L, 176L, 9L, 10L, 76L, 88L, 131L, 181L, 19L, 186L, 136L,
1L, 84L, 366L, 235L, 196L, 224L, 206L, 288L, 204L, 274L, 199L,
239L, 271L, 295L, 266L, 305L, 284L, 340L, 268L, 296L, 293L, 262L,
300L, 212L, 336L, 208L, 358L, 242L, 221L, 237L, 369L, 292L, 201L,
338L, 233L, 217L, 227L, 225L, 270L, 267L, 345L, 205L, 219L, 278L,
337L, 230L, 380L, 291L, 229L, 367L, 339L, 241L, 228L, 263L, 349L,
348L, 371L, 202L, 207L, 351L, 282L, 222L, 200L, 213L, 285L, 375L,
302L, 231L, 223L, 386L, 352L, 363L, 353L, 357L, 359L, 350L, 283L,
362L, 218L, 198L, 374L, 301L, 286L, 364L, 368L, 220L, 298L, 280L,
214L, 273L, 303L, 382L, 354L, 238L, 373L, 234L, 356L, 216L, 289L,
370L, 381L, 343L, 361L, 306L, 281L, 203L, 341L, 355L, 346L, 272L,
264L, 360L, 334L, 210L, 197L, 342L, 299L, 378L, 236L, 333L, 294L,
347L, 275L, 385L, 365L, 209L, 297L, 240L, 265L, 379L, 304L, 269L,
372L, 384L, 344L, 287L, 332L, 376L, 261L, 377L, 383L, 215L, 232L,
277L, 276L, 211L, 290L, 335L, 226L, 279L, 399L, 307L, 395L, 400L,
411L, 388L, 319L, 403L, 320L, 309L, 318L, 407L, 402L, 308L, 326L,
251L, 260L, 246L, 408L, 331L, 312L, 387L, 414L, 253L, 315L, 413L,
416L, 327L, 393L, 322L, 390L, 317L, 389L, 249L, 325L, 329L, 398L,
397L, 323L, 396L, 255L, 415L, 245L, 391L, 412L, 259L, 417L, 311L,
392L, 409L, 328L, 254L, 248L, 310L, 258L, 405L, 324L, 250L, 406L,
316L, 394L, 257L, 404L, 243L, 252L, 410L, 313L, 256L, 330L, 321L,
244L, 401L, 247L, 314L), X = c(0.701250601327047, 0.164821685524657,
0.606994603062049, 0.863256110809743, 0.956295087235048, 0.94587846682407,
0.838799783028662, 0.523805776145309, 0.562612239504233, 0.0359199855010957,
0.142975208582357, 0.459868715610355, 0.579013091977686, 0.384347806917503,
0.161508617224172, 0.96426909067668, 0.504280025139451, 0.438289026031271,
0.373645842541009, 0.439572562696412, 0.25889431219548, 0.0467256724368781,
0.365111395483837, 0.40517632686533, 0.847934616263956, 0.0139284294564277,
0.228810637025163, 0.976755930809304, 0.537870434345677, 0.831849699141458,
0.735547028947622, 0.107985522132367, 0.200033176457509, 0.250281900400296,
0.578671747585759, 0.289995870785788, 0.440369168063626, 0.364585015457124,
0.905479809269309, 0.446940524037927, 0.658691298449412, 0.0173427225090563,
0.24269335786812, 0.430798843270168, 0.164247164269909, 0.357896727975458,
0.381168011575937, 0.466935358708724, 0.598047381266952, 0.236625553574413,
0.075431430246681, 0.729021292412654, 0.332617457257584, 0.800470217363909,
0.658606661716476, 0.857558676274493, 0.95546124689281, 0.319315308239311,
0.26408554892987, 0.736351884901524, 0.998718089656904, 0.0957230781204998,
0.689594832016155, 0.422279811929911, 0.9711551531218, 0.564745565643534,
0.493862147675827, 0.569259794196114, 0.0411112532019615, 
0.0377507081720978,
0.725350870285183, 0.174974237568676, 0.403428635792807, 0.291210540104657,
0.196486078668386, 0.0656222854740918, 0.0509774188976735, 0.78418469009921,
0.907518392894417, 0.718859917717054, 0.162560145836323, 0.165355861652642,
0.239028699230403, 0.794382674852386, 0.258753027301282, 0.856053869239986,
0.753498190781102, 0.128293008776382, 0.97426181170158, 0.73234709375538,
0.88877343875356, 0.0330339481588453, 0.114545000018552, 0.34120128583163,
0.623125589219853, 0.296904754126444, 0.0341241161804646, 0.827014627167955,
0.269123075297102, 0.835532493656501, 0.378544366452843, 0.0417758887633681,
0.701557072810829, 0.991019503446296, 0.430038925725967, 0.30387532315217,
0.212177407694981, 0.0739604290574789, 0.767785993637517, 0.989211868261918,
0.724100521299988, 0.192399453371763, 0.339564701542258, 0.54304352379404,
0.485609688796103, 0.842413938138634, 0.446879531955346, 0.794351557036862,
0.096292131813243, 0.258302961708978, 0.58616296085529, 0.278098736191168,
0.843206173274666, 0.565877866232768, 0.355487501248717, 0.931851770961657,
0.0385297290049493, 0.753262906335294, 0.186055560130626, 0.324502500705421,
0.143642185255885, 0.0232619508169591, 0.618703046115115, 0.340094977291301,
0.458663430297747, 0.313175080576912, 0.311025382485241, 0.740189846139401,
0.387821438955143, 0.127946690190583, 0.0982711461838335, 0.530347143299878,
0.226925036637112, 0.352387776365504, 0.24819467542693, 0.0116725896950811,
0.154650345211849, 0.393079981207848, 0.728091803612188, 0.170153956860304,
0.81173292431049, 0.604964130092412, 0.195516420993954, 0.665194702101871,
0.902374199125916, 0.875123467994854, 0.28142825467512, 0.312998358858749,
0.629422497935593, 0.945258686086163, 0.63372730021365, 0.248635908588767,
0.544222480617464, 0.587964891456068, 0.252189125167206, 0.2657802302856,
0.989964423933998, 0.0520109671633691, 0.211115221725777, 0.723641818389297,
0.21277131116949, 0.999876993708313, 0.115524013759568, 0.107035915134475,
0.807371424278244, 0.558987217256799, 0.831789107760414, 0.824789069592953,
0.26601968659088, 0.0976237277500331, 0.656752997078001, 0.417558990651742,
0.928754845634103, 0.642699809512123, 0.289895867696032, 0.771415231283754,
0.252410312648863, 0.181261786725372, 0.343963136896491, 0.151824467582628,
0.410438629798591, 0.316298315767199, 0.89474390889518, 0.347615822451189,
0.492034191964194, 0.0415450807195157, 0.828365112189204, 0.230966808507219,
0.0422265736851841, 0.402152558788657, 0.684953848132864, 0.899216906866059,
0.922379054129124, 0.550890099955723, 0.42850927147083, 0.146120680728927,
0.222744381986558, 0.637204843340442, 0.975538540631533, 0.533271077787504,
0.0438263991381973, 0.288163386518136, 0.276471544289961, 0.204844454303384,
0.724974561249837, 0.0446081308182329, 0.49430369422771, 0.19497368298471,
2.32525635510683e-05, 0.904675911879167, 0.493794195353985, 
0.72478751721792,
0.142712019383907, 0.663267731433734, 0.231417116709054, 0.0173127462621778,
0.57666564756073, 0.484273905167356, 0.997436377452686, 
0.000396451214328408,
0.510367450769991, 0.591025563655421, 0.224653659854084, 0.773361603729427,
0.379073723452166, 0.448086899705231, 0.041542210849002, 0.309524232754484,
0.647234397474676, 0.637066879775375, 0.616037875413895, 0.162085753167048,
0.958705822238699, 0.602349029621109, 0.598767473595217, 0.113397455308586,
0.698689580429345, 0.825687980279326, 0.290552897378802, 0.507397164823487,
0.397019035648555, 0.223723065108061, 0.701426188694313, 0.850980734452605,
0.756329476134852, 0.0340954945422709, 0.893199543701485, 0.74836050788872,
0.87006417219527, 0.487111459486187, 0.290695097995922, 0.551357613410801,
0.78720832709223, 0.443636126350611, 0.909595184028149, 0.0358559342566878,
0.0801119154784828, 0.839801122667268, 0.666993780760095, 0.577966008568183,
0.422719019465148, 0.630310772219673, 0.883910533739254, 0.941940967924893,
0.232898708432913, 0.539576183073223, 0.285852419212461, 0.481135553214699,
0.565562826581299, 0.345754055306315, 0.862464904552326, 0.793464061338454,
0.0559016007464379, 0.124836669070646, 0.896915214369074, 0.936814778018743,
0.74106968473643, 0.0435592739377171, 0.825898392824456, 0.725313652539626,
0.950716170715168, 0.481058384524658, 0.693162805400789, 0.0216092106420547,
0.277436587261036, 0.402496351627633, 0.719264863058925, 0.439484613249078,
0.398182060336694, 0.236637223977596, 0.244894647505134, 0.479899478610605,
0.165471526794136, 0.0460625963751227, 0.397890231572092, 0.329886695370078,
0.635740406578407, 0.552641975693405, 0.244620074750856, 0.330058194464073,
0.928089746274054, 0.532479231012985, 0.405185123672709, 0.918767123483121,
0.193489346886054, 0.282202445436269, 0.35137809580192, 0.737104135332629,
0.0308404462412, 0.505957348737866, 0.936959875747561, 0.123565464280546,
0.189931713975966, 0.125042418483645, 0.135540294926614, 0.583715724293143,
0.0357968790922314, 0.64392837928608, 0.19056866155006, 0.950899359304458,
0.098964711651206, 0.88134005269967, 0.888160075061023, 0.0511809457093477,
0.702107470482588, 0.608718459727243, 0.416799532948062, 0.117909522727132,
0.633046145318076, 0.88943671900779, 0.803786197211593, 0.775628343923017,
0.290075656725094, 0.592150817392394, 0.741318783024326, 0.77316367207095,
0.44796843174845, 0.635858315508813, 0.295597444288433, 0.600949247833341,
0.76223914208822, 0.419811620842665, 0.705567310331389, 0.708347749663517,
0.263079840457067, 0.50989875337109, 0.973575493320823, 0.94332129508257,
0.819637563312426, 0.192222638521343, 0.396144614787772, 0.983340895501897,
0.827303341357037, 0.756905926857144, 0.22044308623299, 0.59880581847392,
0.535745044238865, 0.722211508080363, 0.871434730477631, 0.11978330113925,
0.652976502198726, 0.732404118636623, 0.861010160297155, 0.89550770772621,
0.36102738394402, 0.597046557813883, 0.694743229541928, 0.80066374479793,
0.664067747537047, 0.698023943696171, 0.730355188250542, 0.569261560449377,
0.906895149964839, 0.534028419991955, 0.161579012637958, 0.486382132628933,
0.176803272450343, 0.996078292140737, 0.166760441381484, 0.130956800654531,
0.412682609632611, 0.667715679854155, 0.337738514645025, 0.51363705820404,
0.881870723795146, 0.724578340072185, 0.941882126033306, 0.158593302126974,
0.452429827069864, 0.491405379958451, 0.973311392823234, 0.99337683757767,
0.249422027729452, 0.930915406672284, 0.46549045224674, 0.878254638286307,
0.059840910602361, 0.998892408795655, 0.114133176626638, 0.234312520828098,
0.300854196073487, 0.149864102946594, 0.636824406450614, 0.671343131922185,
0.872752726078033, 0.00751097011379898, 0.582277687266469), Y = 
c(0.171890107216313,
0.370797614334151, 0.924361743032932, 0.28134711808525, 0.66432327334769,
0.796134414616972, 0.976940092863515, 0.604996162932366, 
0.00418127072043717,
0.316872535273433, 0.99756994890049, 0.309717640280724, 0.131888416828588,
0.245327473850921, 0.645931946812198, 0.92422404163517, 0.339793691877276,
0.261232751654461, 0.900882654357702, 0.64631098182872, 0.00424177665263414,
0.473244683118537, 0.77987119066529, 0.97352181491442, 0.369361791759729,
0.767924362327904, 0.10399404889904, 0.0438599628396332, 0.29301310935989,
0.73782938462682, 0.156529521103948, 0.671467063948512, 0.400057458085939,
0.661995379254222, 0.298377772793174, 0.372027936391532, 0.380989259341732,
0.562391041079536, 0.752812439808622, 0.7302008070983, 0.818077584030107,
0.877294855890796, 0.413850854616612, 0.823451421456411, 0.147629920160398,
0.0302557460963726, 0.773684116546065, 0.589168650330976, 0.468369670212269,
0.388508658157662, 0.611251852475107, 0.148683512816206, 0.240981192560866,
0.625521472422406, 0.69594865757972, 0.845864138565958, 0.0306010833010077,
0.587514291750267, 0.146518325898796, 0.151491977507249, 0.888296207878739,
0.090270600747317, 0.878451642813161, 0.984217442339286, 0.0249567097052932,
0.333548737457022, 0.296019930159673, 0.320528760086745, 0.0295929634012282,
0.635236620903015, 0.392915730830282, 0.439254282508045, 0.0461037687491626,
0.301570050418377, 0.472936083795503, 0.261422283714637, 0.0222742764744908,
0.355823787860572, 0.987022530985996, 0.834863429190591, 0.740066486410797,
0.391710012918338, 0.871678836410865, 0.12019352382049, 0.277163289953023,
0.98267021495849, 0.345335704274476, 0.922220463398844, 0.424633938586339,
0.278999223839492, 0.714344000443816, 0.56897996342741, 0.465939020272344,
0.712276648031548, 0.72533538704738, 0.986942887306213, 0.229512252379209,
0.580829019192606, 0.226183731108904, 0.167294949525967, 0.375515706604347,
0.713610262144357, 0.431350194616243, 0.547398295486346, 0.699540067696944,
0.455317207612097, 0.372894094558433, 0.492133665131405, 0.0603628207463771,
0.23433334287256, 0.758064843481407, 0.064469970529899, 0.240423953859136,
0.142249457305297, 0.101748930523172, 0.368909977609292, 0.235771276289597,
0.465952947735786, 0.191509356489405, 0.136731109814718, 0.304088074946776,
0.802979400614277, 0.543293120339513, 0.0068712888751179, 0.664302490185946,
0.295362222241238, 0.199966921936721, 0.38276062393561, 0.09960433607921,
0.971819909987971, 0.753774431766942, 0.381981828948483, 0.710454542655498,
0.535177865996957, 0.935759501997381, 0.469148830277845, 0.694085463415831,
0.993797857081518, 0.551567627117038, 0.766783748753369, 0.290656099561602,
0.796439147554338, 0.45645066886209, 0.32463817903772, 0.706545975524932,
0.608359589707106, 0.870380551321432, 0.644623076310381, 0.583964630262926,
0.464653216535226, 0.348849157337099, 0.672243025619537, 0.30125402030535,
0.844146094284952, 0.735730222426355, 0.137696442659944, 0.909995779395103,
0.67104962747544, 0.193171724444255, 0.719128533499315, 
0.000234761741012335,
0.115613663569093, 0.43861810490489, 0.359372491715476, 0.0316722302231938,
0.170181025052443, 0.327365997713059, 0.213334964588284, 0.174400835763663,
0.549330030335113, 0.308011762565002, 0.172261784551665, 0.905044082552195,
0.0104124981444329, 0.109363237163052, 0.629955994896591, 0.90461226599291,
0.843848718563095, 0.788788010831922, 0.410448123002425, 0.164807833498344,
0.703740650322288, 0.262160507496446, 0.871268867049366, 0.0789999319240451,
0.373864559689537, 0.0346520259045064, 0.439821641892195, 0.66595608741045,
0.929020783631131, 0.0182372040580958, 0.236733148572966, 0.159761383896694,
0.533487406792119, 0.933626463869587, 0.0902693625539541, 0.441298491321504,
0.542474026791751, 0.564687464153394, 0.126976538216695, 0.789098215056583,
0.38124479772523, 0.228319370187819, 0.921609675046057, 0.208050262648612,
0.239139189943671, 0.396728692576289, 0.817313153296709, 0.560780925443396,
0.400536111090332, 0.441601832862943, 0.988719131564721, 
0.000827041920274496,
0.516230726381764, 0.283795825671405, 0.837254045763984, 0.810963656520471,
0.0731901943217963, 0.75502674584277, 0.572658375371248, 0.588822845835239,
0.69323132908903, 0.454046661267057, 0.0532575217075646, 0.864072882803157,
0.108720119809732, 0.941018613055348, 0.68864845763892, 0.106074716662988,
0.59618656639941, 0.983284626156092, 0.447163598611951, 0.323577877366915,
0.43200644152239, 0.230878660688177, 0.330381851643324, 0.228483391692862,
0.14531171717681, 0.947160384617746, 0.0644653548952192, 0.933858478674665,
0.867367077618837, 0.960713072912768, 0.0106419362127781, 
0.0958437097724527,
0.318360113538802, 0.89607287850231, 0.194603573530912, 0.0140892933122814,
0.78282424225472, 0.154727570246905, 0.762999390950426, 0.489407370565459,
0.423035337822512, 0.19474891689606, 0.681294421199709, 0.225796846672893,
0.6234319685027, 0.636501412605867, 0.159554290119559, 0.553764832671732,
0.0210408298298717, 0.68121306411922, 0.995034355204552, 0.399561397265643,
0.403975014341995, 0.852582210907713, 0.125726311234757, 0.992505229078233,
0.422545881476253, 0.662919480586424, 0.316766428994015, 0.618335535051301,
0.441973085515201, 0.851687799440697, 0.842560255667195, 0.633133036317304,
0.324292129138485, 0.381184502737597, 0.78097918536514, 0.238214250188321,
0.927592432824895, 0.841349175665528, 0.8883684319444, 0.848109701182693,
0.215758525533602, 0.440561114577577, 0.667430794099346, 0.555521365720779,
0.0360126029700041, 0.355077777989209, 0.802172212162986, 
0.0323124176356941,
0.764302607392892, 0.556403563823551, 0.0513982712291181, 0.167700330493972,
0.275772945489734, 0.121303298510611, 0.355494713177904, 0.619331127265468,
0.722270094789565, 0.13826255640015, 0.83197070308961, 0.208093572407961,
0.417050289222971, 0.552277022507042, 0.532353505026549, 0.825634842040017,
0.0584846271667629, 0.206079388037324, 0.55847840802744, 0.787833330687135,
0.265674144495279, 0.632736003026366, 0.935361107578501, 0.892695550108328,
0.810330303385854, 0.504313444718719, 0.484284303616732, 0.268657196313143,
0.79852058342658, 0.837990865344182, 0.0854433339554816, 0.457756362855434,
0.930622784886509, 0.30546832550317, 0.364406730281189, 0.895903791300952,
0.61879310826771, 0.705111734103411, 0.229004139779136, 0.153806942980736,
0.388366017956287, 0.384744216687977, 0.131829720223323, 0.933241792721674,
0.828655388206244, 0.478957881452516, 0.163506358396262, 0.202536955475807,
0.521721071796492, 0.934954703785479, 0.922832843149081, 0.0890378498006612,
0.744039923418313, 0.342938947491348, 0.829126243945211, 0.438954021781683,
0.342147971037775, 0.904643931658939, 0.618884094292298, 0.53136019455269,
0.28578051389195, 0.261097583221272, 0.731547623872757, 0.925990937277675,
0.392090859822929, 0.344719064421952, 0.566447681514546, 0.676267065340653,
0.0889970965217799, 0.79778384277597, 0.454307504929602, 0.0324128807988018,
0.367819492006674, 0.748151563573629, 0.117547858972102, 0.609072768129408,
0.0297117948066443, 0.425113417906687, 0.59103324636817, 0.89295660564676,
0.961610725149512, 0.844706527423114, 0.538759749848396, 0.818922623759136,
0.549228129675612, 0.126476648263633, 0.861659712390974, 0.613700804766268,
0.409116324270144, 0.686794322915375, 0.438312869053334, 0.878093276405707,
0.755687783006579, 0.00695069995708764, 0.138217013562098, 
0.411313445540145,
0.907310962677002, 0.701067975489423, 0.1852589645423, 0.150231995387003,
0.934385694563389, 0.353562438627705, 0.464768649777398, 0.765283492859453,
0.905872487463057, 0.0849798938725144, 0.773121788864955, 
0.0939909212756902,
0.596990453079343, 0.725830281618983, 0.598506234120578, 0.458693271037191,
0.281013652216643, 0.458665299229324, 0.0339348095003515, 0.799791351892054,
0.000570902600884438, 0.804609716171399, 0.812421002890915, 
0.886078594485298,
0.525463038356975, 0.145692070946097, 0.78209150978364, 0.905050198314711
), A = structure(c(1L, 3L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L,
1L, 3L, 2L, 2L, 1L, 3L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 3L,
1L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 3L, 1L, 2L, 1L, 1L, 1L,
2L, 3L, 2L, 3L, 3L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 3L, 1L, 2L, 2L, 2L, 3L, 1L, 1L, 3L, 1L, 2L, 3L, 2L, 3L, 2L,
1L, 1L, 1L, 1L, 3L, 1L, 3L, 2L, 1L, 1L, 1L, 3L, 1L, 2L, 2L, 2L,
2L, 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, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
     4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
     4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
     4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
     4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
     4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
     5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
     5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
     5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
     5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
     5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L)), .Names = 
c("rown",
"X", "Y", "A", "B", "C"), row.names = c(91L, 193L, 128L, 8L,
143L, 46L, 60L, 99L, 112L, 67L, 25L, 15L, 188L, 93L, 115L, 4L,
190L, 64L, 147L, 119L, 82L, 120L, 23L, 139L, 28L, 42L, 180L,
24L, 145L, 71L, 13L, 95L, 94L, 104L, 149L, 74L, 32L, 184L, 11L,
114L, 90L, 70L, 63L, 141L, 192L, 126L, 153L, 172L, 26L, 151L,
109L, 133L, 79L, 35L, 61L, 43L, 52L, 29L, 30L, 80L, 154L, 7L,
121L, 122L, 106L, 182L, 16L, 2L, 175L, 34L, 102L, 174L, 117L,
178L, 100L, 68L, 48L, 31L, 53L, 168L, 59L, 165L, 123L, 69L, 55L,
62L, 163L, 39L, 108L, 96L, 97L, 113L, 87L, 164L, 169L, 33L, 118L,
45L, 148L, 129L, 22L, 116L, 101L, 157L, 191L, 89L, 75L, 156L,
137L, 183L, 98L, 150L, 124L, 144L, 127L, 155L, 57L, 36L, 14L,
161L, 187L, 138L, 111L, 146L, 20L, 107L, 140L, 110L, 125L, 41L,
105L, 159L, 103L, 132L, 44L, 166L, 56L, 171L, 195L, 40L, 135L,
5L, 58L, 37L, 54L, 83L, 17L, 142L, 77L, 162L, 170L, 160L, 78L,
38L, 194L, 21L, 167L, 27L, 81L, 185L, 47L, 66L, 73L, 3L, 134L,
158L, 51L, 173L, 50L, 18L, 12L, 6L, 189L, 72L, 85L, 65L, 92L,
179L, 86L, 49L, 130L, 177L, 152L, 176L, 9L, 10L, 76L, 88L, 131L,
181L, 19L, 186L, 136L, 1L, 84L, 366L, 235L, 196L, 224L, 206L,
288L, 204L, 274L, 199L, 239L, 271L, 295L, 266L, 305L, 284L, 340L,
268L, 296L, 293L, 262L, 300L, 212L, 336L, 208L, 358L, 242L, 221L,
237L, 369L, 292L, 201L, 338L, 233L, 217L, 227L, 225L, 270L, 267L,
345L, 205L, 219L, 278L, 337L, 230L, 380L, 291L, 229L, 367L, 339L,
241L, 228L, 263L, 349L, 348L, 371L, 202L, 207L, 351L, 282L, 222L,
200L, 213L, 285L, 375L, 302L, 231L, 223L, 386L, 352L, 363L, 353L,
357L, 359L, 350L, 283L, 362L, 218L, 198L, 374L, 301L, 286L, 364L,
368L, 220L, 298L, 280L, 214L, 273L, 303L, 382L, 354L, 238L, 373L,
234L, 356L, 216L, 289L, 370L, 381L, 343L, 361L, 306L, 281L, 203L,
341L, 355L, 346L, 272L, 264L, 360L, 334L, 210L, 197L, 342L, 299L,
378L, 236L, 333L, 294L, 347L, 275L, 385L, 365L, 209L, 297L, 240L,
265L, 379L, 304L, 269L, 372L, 384L, 344L, 287L, 332L, 376L, 261L,
377L, 383L, 215L, 232L, 277L, 276L, 211L, 290L, 335L, 226L, 279L,
399L, 307L, 395L, 400L, 411L, 388L, 319L, 403L, 320L, 309L, 318L,
407L, 402L, 308L, 326L, 251L, 260L, 246L, 408L, 331L, 312L, 387L,
414L, 253L, 315L, 413L, 416L, 327L, 393L, 322L, 390L, 317L, 389L,
249L, 325L, 329L, 398L, 397L, 323L, 396L, 255L, 415L, 245L, 391L,
412L, 259L, 417L, 311L, 392L, 409L, 328L, 254L, 248L, 310L, 258L,
405L, 324L, 250L, 406L, 316L, 394L, 257L, 404L, 243L, 252L, 410L,
313L, 256L, 330L, 321L, 244L, 401L, 247L, 314L), class = "data.frame")

library("ggplot2")

ggplot(data=broken) +
geom_point(aes(x=X, y=Y, shape=C, colour=B)) +
facet_wrap(~A)

ggplot2 makes this (mapping different data values to different 
aesthetics (e.g. color, shape, etc.) of the plot) relatively 
straightforward.

-- 
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health & Science University



More information about the R-help mailing list