<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>facet &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/facet/</link>
	<description>Feed of posts on WordPress.com tagged "facet"</description>
	<pubDate>Sat, 28 Nov 2009 08:58:09 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[christmas time cz.3 - szkoła przetrwania dla Niego]]></title>
<link>http://evi219.wordpress.com/2009/11/23/christmas-time-3-szkola-przetrwania-dla-niego/</link>
<pubDate>Mon, 23 Nov 2009 16:57:45 +0000</pubDate>
<dc:creator>evi219</dc:creator>
<guid>http://evi219.wordpress.com/2009/11/23/christmas-time-3-szkola-przetrwania-dla-niego/</guid>
<description><![CDATA[Wyobraź sobie, że siedzisz przy wigilijnym stole. Na twarzy masz uśmiech no.5 przeznaczony specjalni]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Wyobraź sobie, że siedzisz przy wigilijnym stole. Na twarzy masz uśmiech no.5 przeznaczony specjalnie na takie okazje &#8211; dobry uśmiech do złej gry. Z każdą godziną krew w Twoich żyłach coraz bardziej się gotuje. Toczysz walkę z samym sobą. Czy dalej będziesz siedzieć spokojnie tłumiąc w sobie gniew i złość, czy uderzysz ręką w stół i wyjdziesz, kończąc tym samym całą tą farsę?</p>
<p>Oczywiście zostajesz. Tak jak co roku.</p>
<p>W kieszeni otwiera Ci się scyzoryk.  Ty zaś ze stoickim spokojem dalej wysłuchujesz narzekań na polityków, historie przebytych chorób, żenujące opowiastki z twojego dzieciństwa, litanie kąśliwych uwag na swój temat oraz krzyki dzieci biegających wokół stołu&#8230; W głębi serca obiecujesz sobie, że to już ostatni raz&#8230; Za rok to nie będzie tak wyglądać, bo wyjedziesz gdzieś daleko stąd i będziesz mieć wreszcie święty spokój.</p>
<p>Jak przetrwać święta bez konieczności popełnienia krwawej zbrodni&#8230;? Panowie, mam dla Was kilka propozycji:</p>
<p style="padding-left:30px;">1. Oczywiście najprostszym rozwiązaniem było by uciec na drugi koniec świata. Najlepiej gdzieś, gdzie nikt nie słyszał o istnieniu Świąt Bożego Narodzenia. No ale to niestety graniczyłoby z cudem&#8230;</p>
<p style="padding-left:30px;">2. Niech Święta będą dla Ciebie nowym wyzwaniem. Kolejnym etapem twojej ulubionej gry komputerowej, który po prostu musisz przejść dalej cokolwiek by się nie działo!</p>
<p style="padding-left:30px;">3. Popatrz na to co się dzieje dookoła Ciebie jak na kabaret. Z tą tylko jedyną różnicą, że nie oglądasz tego skeczu z widowni, ale przez przypadek znalazłeś się na scenie.</p>
<p style="padding-left:30px;">4. Bądź ponad wszystko. Bądź dumny i wyniosły. Nie daj sobie w kaszę dmuchać. I spoglądaj na innych z politowaniem. Gwarantuję, że szybko dadzą Ci spokój.</p>
<p style="padding-left:30px;">5. Potraktuj święta jako test własnej wytrzymałości psychicznej. Wyobraź sobie, jak wielka będzie twoja satysfakcja, że kolejne święta masz za sobą. Będziesz z siebie dumny.</p>
<p style="padding-left:30px;">6. Jeśli jednak na własnej skórze przekonałeś się, że akurat w twoim przypadku powyższe metody nie zdały egzaminu, masz jeszcze jedno wyjście&#8230; Upij się. Zachlaj do nieprzytomności. Wtedy będzie Ci już wszystko jedno. Nie będziesz się niczym przejmować, nie będziesz mieć złych wspomnień &#8211; pomijając ewentualnego kaca jaki Cię dopadnie następnego dnia. Jedynym twoim zmartwieniem później będzie zastanawianie się dlaczego żona kazała Ci spać na kanapie, siostra od tygodni nie odbiera twoich telefonów, a kuzynka mijając Cię na ulicy odwraca wzrok&#8230;</p>
<p>P.S. Stosujecie powyższe rady tylko i wyłącznie na własną odpowiedzialność. Reklamacji i zażaleń nie przyjmuję!</p>
<p>Merry Christmas!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Sebastian Boenisch w reprezentacji?]]></title>
<link>http://neewsy.wordpress.com/2009/11/09/sebastian-boenisch-w-reprezentacji/</link>
<pubDate>Mon, 09 Nov 2009 12:16:28 +0000</pubDate>
<dc:creator>printex</dc:creator>
<guid>http://neewsy.wordpress.com/2009/11/09/sebastian-boenisch-w-reprezentacji/</guid>
<description><![CDATA[Wszystko wskazuje na to, że jednak Sebastian Boenisch zagra dla reprezentacji Polski w piłce nożnej ]]></description>
<content:encoded><![CDATA[Wszystko wskazuje na to, że jednak Sebastian Boenisch zagra dla reprezentacji Polski w piłce nożnej ]]></content:encoded>
</item>
<item>
<title><![CDATA[Managing and growing a cultural heritage web presence]]></title>
<link>http://electronicmuseum.org.uk/2009/11/06/managing-and-growing-a-cultural-heritage-web-presence/</link>
<pubDate>Fri, 06 Nov 2009 12:24:13 +0000</pubDate>
<dc:creator>Mike</dc:creator>
<guid>http://electronicmuseum.org.uk/2009/11/06/managing-and-growing-a-cultural-heritage-web-presence/</guid>
<description><![CDATA[I&#8217;m absolutely delighted (and only slightly scared) to announce that I&#8217;ve been commissio]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I&#8217;m absolutely delighted (and only slightly scared) to announce that I&#8217;ve been commissioned to write a book for <a href="http://www.facetpublishing.co.uk/">Facet Publishing</a>.</p>
<p>Ever since I started working with museums online, I&#8217;ve felt that there is a need for strategic advice to help managers of cultural heritage web presences. There are of course hundreds of thousands of resources if you&#8217;ve got technical questions, but not many places where you can ask things like &#8220;how should I build my web team and structure my budget?&#8221; or &#8220;how do I write a strategy or business plan?&#8221;.</p>
<p>Facet approached me in July asking whether I&#8217;d be interested in authoring something for them, and this seemed like the ideal opportunity to try and answer some of these questions.</p>
<p>My (draft) synposis is as follows:</p>
<blockquote><p><em>This book will provide a guide for anyone looking to build or maintain a cultural heritage web presence. It will aim to cater both to those who are single-handedly trying to keep their site running on limited budget and time as well as those who have big teams, large budgets and time to spend.</em></p>
<p><em>As well as describing the strategic approaches which are required to develop a successful online presence, the book will contain data and case studies on current practice from large and small cultural heritage institutions. This research will help give the reader an insight into how these institutions manage their websites as well as providing hints and tips on best practice. It will have an accompanying web presence which will provide template downloads and other up-to-date information including links and white papers.</em></p></blockquote>
<p>As you&#8217;ll see, I have no intention of trying to do this all by myself &#8211; over the coming year I&#8217;m going to be on the phone to many of you (hide now!) asking how you do what you do, and compiling this into what I hope will be a useful guide.</p>
<p>If you have any ideas about what I should include, or the questions I should be asking &#8211; please do get in touch either via this blog or on Twitter at <a href="http://twitter.com/m1ke_ellis">@m1ke_ellis</a>!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[robię dobrze facetom]]></title>
<link>http://sexanons.wordpress.com/2009/10/28/robie-dobrze-facetom/</link>
<pubDate>Wed, 28 Oct 2009 11:36:37 +0000</pubDate>
<dc:creator>majhu</dc:creator>
<guid>http://sexanons.wordpress.com/2009/10/28/robie-dobrze-facetom/</guid>
<description><![CDATA[Jestem laska, co dobrze robi facetom, biorę za to trzy stówy, ekskluzywna dziwka ze mnię i bzykam si]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Jestem laska, co dobrze robi facetom, biorę za to trzy stówy, ekskluzywna dziwka ze mnię i bzykam sie tylko w hotelach. Zadnych moteli i innych gównianych miejsc. CHcesz bzyknąć ekskluzywną dziwkę? masz 300zł za godzinę? dawaj, czekam na Ciebie, bo wbrew pozorom niewielu jest na mnie stać. Paranoiku jebany, chodź, przelecę Cię tak że sperma Ci tyłkiem wyleci. Dawaj!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Łukasz Rząsa]]></title>
<link>http://tomeklesniak.wordpress.com/2009/10/13/lukasz-rzasa/</link>
<pubDate>Tue, 13 Oct 2009 08:55:18 +0000</pubDate>
<dc:creator>Tomek</dc:creator>
<guid>http://tomeklesniak.wordpress.com/2009/10/13/lukasz-rzasa/</guid>
<description><![CDATA[]]></description>
<content:encoded><![CDATA[]]></content:encoded>
</item>
<item>
<title><![CDATA[Facet Design and Packaging]]></title>
<link>http://ambalaj.se/2009/10/04/facet-design-into-packaging-design/</link>
<pubDate>Sun, 04 Oct 2009 18:52:05 +0000</pubDate>
<dc:creator>ambalaj</dc:creator>
<guid>http://ambalaj.se/2009/10/04/facet-design-into-packaging-design/</guid>
<description><![CDATA[Dzmitry Samal has made the faceted tin concept on the first picture. And with this concept I would l]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p style="text-align:center;"><img class="size-full wp-image-1441 aligncenter" title="coca_cola_facet_design" src="http://ambalaj.wordpress.com/files/2009/10/coca_cola_facet_design.jpg" alt="coca_cola_facet_design" width="550" height="322" /></p>
<p style="text-align:center;"><img class="alignnone size-full wp-image-1447" title="vitaminwater_packaging_concept" src="http://ambalaj.wordpress.com/files/2009/10/vitaminwater_packaging_concept.jpg" alt="vitaminwater_packaging_concept" width="550" height="382" /></p>
<p style="text-align:center;"><img class="size-full wp-image-1449 aligncenter" title="carbon_shaker_salt_pepper" src="http://ambalaj.wordpress.com/files/2009/10/carbon_shaker_salt_pepper1.png" alt="carbon_shaker_salt_pepper" width="550" height="202" /></p>
<p style="text-align:center;"><img class="alignnone size-full wp-image-1460" title="engineered_flowers_3" src="http://ambalaj.wordpress.com/files/2009/10/engineered_flowers_3.jpg" alt="engineered_flowers_3" /></p>
<p style="text-align:left;">Dzmitry Samal has made the faceted tin concept on the first picture. And with this concept I would like to bring you into what I think is a fabulous document. This <a href="http://everybodyisartdirector.typepad.com/files/everyone-is-an-art-director---trend-book-1.pdf" target="_blank">Facet Design Book</a> is a fantastic source of inspiration. Scroll through it and you will probably end up having a bunch of ideas. Beautiful! On the same theme Vitamin Water &#8211; new label, with the facet design incorporated in the graphic design. Designed by <a href="http://www.thecoolhunter.net/article/detail/1615/tch-x-vitamin-water-design-competition">The Coolhunter</a>. The salt and pepper dispenser, designed by Gregory Buntain. And last Fract Engineered Flowers, by Nimrod Gavish.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Telegraf semtymentalny]]></title>
<link>http://dzokero.wordpress.com/2009/09/27/telegraf-semtymentalny/</link>
<pubDate>Sun, 27 Sep 2009 08:31:43 +0000</pubDate>
<dc:creator>dzokero</dc:creator>
<guid>http://dzokero.wordpress.com/2009/09/27/telegraf-semtymentalny/</guid>
<description><![CDATA[Na studiach wracało sie z sobotnich imprez przeważnie o 2-3. W dzisiejszych czasach 23 i już w domu ]]></description>
<content:encoded><![CDATA[Na studiach wracało sie z sobotnich imprez przeważnie o 2-3. W dzisiejszych czasach 23 i już w domu ]]></content:encoded>
</item>
<item>
<title><![CDATA[Roll Resistant Coke Can Concept]]></title>
<link>http://phlodsurboat.wordpress.com/2009/09/26/roll-resistant-coke-can-concept/</link>
<pubDate>Sat, 26 Sep 2009 13:03:07 +0000</pubDate>
<dc:creator>cokeforbreakfast</dc:creator>
<guid>http://phlodsurboat.wordpress.com/2009/09/26/roll-resistant-coke-can-concept/</guid>
<description><![CDATA[faceted rather than round. interesting&#8230;. Roll Resistant Coke Can Concept via PSFK.]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>faceted rather than round. interesting&#8230;.</p>
<p style="text-align:center;"><a href="http://www.psfk.com/2009/09/roll-resistant-coke-can-concept.html"><img src='http://phlodsurboat.files.wordpress.com/2009/09/dzmitry_samal_coke_1jpg-525x495.jpg' alt='' /></a></p>
<p><a href="http://www.psfk.com/2009/09/roll-resistant-coke-can-concept.html">Roll Resistant Coke Can Concept via PSFK</a>.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[uwodzic.wordpress - Uwodzenie pięknych kobiet na randce. ]]></title>
<link>http://uwodzic.wordpress.com/2009/09/25/uwodzenie-pieknych-kobiet-na-randce/</link>
<pubDate>Thu, 24 Sep 2009 22:37:15 +0000</pubDate>
<dc:creator>pawlooo84</dc:creator>
<guid>http://uwodzic.wordpress.com/2009/09/25/uwodzenie-pieknych-kobiet-na-randce/</guid>
<description><![CDATA[W jaki sposób uwodzić piękne kobiety oraz dziewczyny, wydające się wysoce niedostępne, co nie koniec]]></description>
<content:encoded><![CDATA[W jaki sposób uwodzić piękne kobiety oraz dziewczyny, wydające się wysoce niedostępne, co nie koniec]]></content:encoded>
</item>
<item>
<title><![CDATA[ggplot2: Back-to-back Bar Charts]]></title>
<link>http://learnr.wordpress.com/2009/09/24/ggplot2-back-to-back-bar-charts/</link>
<pubDate>Wed, 23 Sep 2009 22:50:20 +0000</pubDate>
<dc:creator>learnr</dc:creator>
<guid>http://learnr.wordpress.com/2009/09/24/ggplot2-back-to-back-bar-charts/</guid>
<description><![CDATA[On the ggplot2 mailing-list the following question was asked: How to create a back-to-back bar chart]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>On the <tt>ggplot2</tt> mailing-list the following question <a href="http://groups.google.com/group/ggplot2/browse_thread/thread/47c94337c9b81a9d/f2223b2baf03864b?show_docid=f2223b2baf03864b">was asked</a>:</p>
<blockquote><p>How to create a back-to-back bar chart with ggplot2?</p>
<p>For anyone who don&#8217;t know what I am talking about, have a look on a recent <a href="http://ec.europa.eu/agriculture/publi/map/02_09.pdf">paper from the EU</a>. I&#8217;d like to create plots like the graphs 5,6,18 in the paper.</p>
<p align="right">
</blockquote>
<p>An example graph from the above report is below:</p>
<div align="center"> <img src="http://learnr.files.wordpress.com/2009/09/export_import_graph5.png" style="border-width:0;" alt="export_import_graph5.png"> </div>
<p>Let&#8217;s create the same graph in <a href="http://had.co.nz/ggplot2/"><tt>ggplot2</tt></a>.</p>
<p> <!--more-->
<p>I was not able to find the exact dataset used to plot the graph above, and used instead the Eurostat &#8220;EU27 trade by BEC product group since 1999&#8243;  <a href="http://nui.epp.eurostat.ec.europa.eu/nui/show.do?dataset=ext_st_eu27bec&#38;lang=en">dataset</a> which has a very similar data structure.</p>
<p>Access the subset used in this post in <a href="http://pastie.org/pastes/629247/download">here</a>.</p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; library(ggplot2)</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; trade &#60;- read.csv("trade.csv", header = TRUE,
     stringsAsFactors = FALSE)</pre>
</td>
</tr>
</table>
<p>Calculate monthly total trade balances.</p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; balance &#60;- ddply(trade, .(Time), summarise,
     balance = sum(EXP - IMP))</pre>
</td>
</tr>
</table>
<p>Convert data from wide format to long format for plotting.</p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; trade.m &#60;- melt(trade, id.vars = c("BEC", "Time"))</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; ggplot(trade.m, aes(Time)) + geom_bar(subset = .(variable ==
     "EXP"), aes(y = value, fill = BEC), stat = "identity") +
     geom_bar(subset = .(variable == "IMP"),
         aes(y = -value, fill = BEC), stat = "identity") +
     xlab("") + scale_y_continuous("Export  -  Import",
     formatter = "comma")</pre>
</td>
</tr>
</table>
<div align="center"> <img src="http://learnr.files.wordpress.com/2009/09/export_import1.png" style="border-width:0;" alt="export_import1.png"> </div>
<p>Add horizontal line at 0 for easier reading, plot the trade balance line and make the x-axis labels more readable.</p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; labels &#60;- gsub("20([0-9]{2})M([0-9]{2})", "\\2\n\\1",
     trade.m$Time)
&#62; last_plot() + geom_line(data = balance, aes(Time,
     balance, group = 1), size = 1) + geom_hline(yintercept = 0,
     colour = "grey90") + scale_x_discrete(labels = labels)</pre>
</td>
</tr>
</table>
<div align="center"> <img src="http://learnr.files.wordpress.com/2009/09/export_import21.png" style="border-width:0;" alt="export_import2.png"> </div>
<p>The legend explanation (too large to fit on the plot):</p>
<ul>
<li> CAP  Capital goods </li>
<li> CNS  Consumption goods </li>
<li> CTR  Consumption goods plus motor spirit and passenger motor cars </li>
<li> INT  Intermediate goods </li>
</ul>
<p>There shouldn&#8217;t be any negative numbers on the y-axis, we need a custom formatter to convert these to positive.</p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; commapos &#60;- function(x, ...) {
     format(abs(x), big.mark = ",", trim = TRUE,
         scientific = FALSE, ...)
 }</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; last_plot() + scale_y_continuous(formatter = "commapos")</pre>
</td>
</tr>
</table>
<div align="center"> <img src="http://learnr.files.wordpress.com/2009/09/export_import31.png" style="border-width:0;" alt="export_import3.png"> </div>
<p>I have to agree with some of the posters on the mailing list, that this type of chart is not very easy to follow &#8211; it is impossible to compare individual values. Another useful way of showing information would be to use facets:</p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; ggplot(trade.m, aes(Time)) + geom_bar(aes(y = value),
     stat = "identity") + facet_grid(variable ~
     BEC) + scale_x_discrete("", labels = labels) +
     scale_y_continuous(formatter = "comma")</pre>
</td>
</tr>
</table>
<div align="center"> <img src="http://learnr.files.wordpress.com/2009/09/export_import3a1.png" style="border-width:0;" alt="export_import3a.png"> </div>
<p>Or combine export and import values on one plot showing the comparative trend between the different goods categories.</p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; ggplot(trade.m, aes(Time, colour = variable,
     group = variable)) + geom_line(aes(y = value)) +
     facet_grid(BEC ~ .) + scale_x_discrete("",
     labels = labels) + scale_y_continuous(formatter = "comma")</pre>
</td>
</tr>
</table>
<div align="center"> <img src="http://learnr.files.wordpress.com/2009/09/export_import41.png" style="border-width:0;" alt="export_import4.png"> </div>
<p>The same graph with varying scales across panels.</p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; last_plot() + facet_grid(BEC ~ ., scales = "free_y")</pre>
</td>
</tr>
</table>
<div align="center"> <img src="http://learnr.files.wordpress.com/2009/09/export_import51.png" style="border-width:0;" alt="export_import5.png"> </div>
<p><strong><em>Update:</em></strong> As suggested in the comments it would be good to have total values added to the last plot.</p>
<p>In order to do so the totals are first calculated and then appended to the original dataframe.</p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; total &#60;- ddply(trade.m, .(Time, variable),
     summarise, value = sum(value), BEC = "Total")
&#62; total &#60;- rbind(trade.m, total)</pre>
</td>
</tr>
</table>
<p>Plotting the new dataframe is just a question of changing the source of the last plot.</p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; last_plot() %+% total</pre>
</td>
</tr>
</table>
<div align="center"> <img src="http://learnr.files.wordpress.com/2009/09/export_import6.png" style="border-width:0;" alt="export_import6.png"> </div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[uwodzic.wordpress - Jakich mężczyzn naprawdę lubią kobiety?]]></title>
<link>http://uwodzic.wordpress.com/2009/09/23/uwodzic-wordpress-jakich-mezczyzn-naprawde-lubia-kobiety/</link>
<pubDate>Tue, 22 Sep 2009 23:30:07 +0000</pubDate>
<dc:creator>pawlooo84</dc:creator>
<guid>http://uwodzic.wordpress.com/2009/09/23/uwodzic-wordpress-jakich-mezczyzn-naprawde-lubia-kobiety/</guid>
<description><![CDATA[Obiegowa opinia głosząca, że kobiety kochają tylko dobrze zbudowanych mężczyzn z okazałym portfelem,]]></description>
<content:encoded><![CDATA[Obiegowa opinia głosząca, że kobiety kochają tylko dobrze zbudowanych mężczyzn z okazałym portfelem,]]></content:encoded>
</item>
<item>
<title><![CDATA[A Guide to Effective Witnessing:]]></title>
<link>http://jbutzu.wordpress.com/2009/09/20/a-list-to-guide-effective-witnessing/</link>
<pubDate>Mon, 21 Sep 2009 02:24:28 +0000</pubDate>
<dc:creator>jbutzu</dc:creator>
<guid>http://jbutzu.wordpress.com/2009/09/20/a-list-to-guide-effective-witnessing/</guid>
<description><![CDATA[Here is a quick list that I hope will at least be considered by those who wish God to use them in th]]></description>
<content:encoded><![CDATA[Here is a quick list that I hope will at least be considered by those who wish God to use them in th]]></content:encoded>
</item>
<item>
<title><![CDATA[Logistics: Currency Rate of Exchange]]></title>
<link>http://asifjmir.wordpress.com/2009/09/09/logistics-currency-rate-of-exchange/</link>
<pubDate>Wed, 09 Sep 2009 02:39:54 +0000</pubDate>
<dc:creator>Asif Mir</dc:creator>
<guid>http://asifjmir.wordpress.com/2009/09/09/logistics-currency-rate-of-exchange/</guid>
<description><![CDATA[Variations in the rate of exchange of the dollar against foreign currencies represent a difference o]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Variations in the rate of exchange of the dollar against foreign currencies represent a difference of major importance in international logistics just as they do in any other facet of international operations. The design and operation of an international logistic system is based on a set of units of measure. Thus, as rates of exchange vary, so do the local costs associated with different local currencies; these include transportation, warehousing, inventorying, information processing, and other costs elements.</p>
<p>When variations in rates of exchange become substantial in magnitude, and significantly different between countries, it is usually necessary to re-evaluate the structure of the logistic system, to ensure that it is adjusted to keep it close to its optimal performance. By the same token, management reports must provide explicit identification of variations in costs due to variations in currency rates of exchange, as opposed to variations in performance.</p>
<p>My Consultancy–<a title="Asif J. Mir" href="http://www.asifjmir.com/" target="_blank">Asif J. Mir </a>- Management Consultant–transforms organizations where people have the freedom to be creative, a place that brings out the best in everybody–an open, fair place where people have a sense that what they do matters. For details please visit <a title="Asif J. Mir" href="http://www.asifjmir.com/" target="_blank">www.asifjmir.com</a>, <a title="Line of Sight" href="http://asifjmir.blogspot.com/" target="_blank">Line of Sight</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Facets]]></title>
<link>http://lunzer.wordpress.com/2009/09/08/facets/</link>
<pubDate>Tue, 08 Sep 2009 23:25:58 +0000</pubDate>
<dc:creator>quock</dc:creator>
<guid>http://lunzer.wordpress.com/2009/09/08/facets/</guid>
<description><![CDATA[What are actually facets and can they be seen as structured features for bio-models? What is facet c]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>What are actually facets and can they be seen as structured features for bio-models? What is<a href="http://en.wikipedia.org/wiki/Faceted_classification"> facet classification</a> and who uses it?</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Gołe dupy]]></title>
<link>http://dopoczytania.wordpress.com/2009/09/07/gole-dupy/</link>
<pubDate>Mon, 07 Sep 2009 16:58:48 +0000</pubDate>
<dc:creator>artmaster2</dc:creator>
<guid>http://dopoczytania.wordpress.com/2009/09/07/gole-dupy/</guid>
<description><![CDATA[Jestem ciekaw dlaczego na kobiety nie raz zwykło się słyszeć określenie, ale dupa. Przecież dupa wia]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Jestem ciekaw dlaczego na kobiety nie raz zwykło się słyszeć określenie, ale dupa. Przecież dupa wiadomo do czego służy. Może facetom po prostu chodzi o to, że ma fjane pośladki. W końcu kształt pośladków ma to do siebie, że Nas przyciagą, a w języku natury oznacza to dokładniej, jestem gotowa do kopulacji.</p>
<p>Ale to tyle jeśli chodzi o język natury. Niemiej bardziej zachęcające jest określenie <a href="http://gole-dupy.fxlayer.net/">gołe dupy</a>. Co to by miało oznaczać, sam dokładnie nie wiem. Ale właśnie takich wyrażeń według Google wyszukują niektórzy użytkownicy tej wyszukiwarki internetowej. Przypuszczam, że mają tu na myśli rozebrane panieniki, które np. dają dupy na filmach porno.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[NEWS FLASH, NEWS FLASH!!!!]]></title>
<link>http://skydi.wordpress.com/2009/09/07/news-flash-news-flash/</link>
<pubDate>Mon, 07 Sep 2009 16:48:05 +0000</pubDate>
<dc:creator>skydi</dc:creator>
<guid>http://skydi.wordpress.com/2009/09/07/news-flash-news-flash/</guid>
<description><![CDATA[WOW! 2PLUS7 has passed! $500,000 mark for commission payouts. $520,000 in just 2 MONTHS! This is the]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>WOW! 2PLUS7 has passed! $500,000 mark for commission payouts. $520,000 in just 2 MONTHS! This is the<br />
&#8220;Incredible System Never Sleeps&#8221;.  We are getting 400 signups a day! Now can you agree with me that we have something VERY SPECIAL for the MASSES!</p>
<p>Here are some short videos to help you understand what 2plus7 is all about.  Enjoy and then Contact Me Today! Don&#8217;t Wait! &#8230;Diana</p>
<p><a href="http://www.power27.com/skydigold27/Benefits-Overview">Benefits, Benefits, Benefits Overview</a></p>
<p><a href="http://www.power27.com/skydigold27/Security">Security in this Recession Downturn</a></p>
<p><a href="http://www.power27.com/skydigold27/90-Seconds">Turn Your Life Around in 90 Seconds</a></p>
<p><a href="http://www.power27.com/skydigold27/How-It-Works">How It Works</a></p>
<p>viewfromtop@gmail.com</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Wallpaper* (Thai Edition) - Nov, 2008]]></title>
<link>http://pressofanonpairot.wordpress.com/2009/08/27/wallpaper-thai-edition-nov-2008/</link>
<pubDate>Thu, 27 Aug 2009 10:24:13 +0000</pubDate>
<dc:creator>cheffykung</dc:creator>
<guid>http://pressofanonpairot.wordpress.com/2009/08/27/wallpaper-thai-edition-nov-2008/</guid>
<description><![CDATA[]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><a href="http://www.anonpairot.com/press/2008-11-03-00.jpg"><img class="alignnone size-full wp-image-81" title="2008-11-03-00" src="http://pressofanonpairot.wordpress.com/files/2009/08/2008-11-03-00.jpg" alt="2008-11-03-00" width="500" height="527" /></a></p>
<p><img class="alignnone size-full wp-image-82" title="2008-11-03-01" src="http://pressofanonpairot.wordpress.com/files/2009/08/2008-11-03-01.jpg" alt="2008-11-03-01" width="500" height="350" /></p>
<p><a href="http://www.anonpairot.com/press/2008-11-03-02.jpg"><img class="alignnone size-full wp-image-83" title="2008-11-03-02" src="http://pressofanonpairot.wordpress.com/files/2009/08/2008-11-03-02.jpg" alt="2008-11-03-02" width="500" height="357" /></a></p>
<p><a href="http://www.anonpairot.com/press/2008-11-03-03.jpg"><img class="alignnone size-full wp-image-84" title="2008-11-03-03" src="http://pressofanonpairot.wordpress.com/files/2009/08/2008-11-03-03.jpg" alt="2008-11-03-03" width="500" height="346" /></a></p>
<p><a href="http://www.anonpairot.com/press/2008-11-03-04.jpg"><img class="alignnone size-full wp-image-85" title="2008-11-03-04" src="http://pressofanonpairot.wordpress.com/files/2009/08/2008-11-03-04.jpg" alt="2008-11-03-04" width="500" height="347" /></a></p>
<p><a href="http://www.anonpairot.com/press/2008-11-03-05.jpg"><img class="alignnone size-full wp-image-86" title="2008-11-03-05" src="http://pressofanonpairot.wordpress.com/files/2009/08/2008-11-03-05.jpg" alt="2008-11-03-05" width="500" height="368" /></a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Ciągi i pociągi.]]></title>
<link>http://autoteliczna.wordpress.com/2009/08/27/ciagi-i-pociagi/</link>
<pubDate>Wed, 26 Aug 2009 23:24:48 +0000</pubDate>
<dc:creator>autoteliczna</dc:creator>
<guid>http://autoteliczna.wordpress.com/2009/08/27/ciagi-i-pociagi/</guid>
<description><![CDATA[Nie wiem jak to się stało, ale w końcu zaczęliśmy się spotykać. Spotykać na zasadzie, że jesteśmy ra]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Nie wiem jak to się stało, ale w końcu zaczęliśmy się spotykać. Spotykać na zasadzie, że jesteśmy razem. Zawsze o tym marzyłam. Tego pragnęłam w głębi serca najbardziej na świecie. Marzenie w końcu się spełniło. Po długim czasie oczekiwania, zwykłej przyjaźni oboje uzmysłowiliśmy sobie, że nie możemy bez siebie żyć. Bez naszych rozmów, naszej obecności. Że nie ma drugiej takiej osoby, która tak dobrze by nas rozumiała, przy której nie musieliśmy udawać.</p>
<p>Spotykaliśmy się już jakiś czas i lubiliśmy kochać się w różnych dziwnych miejscach. Było zawsze przy tym tyle zabawy. I ta adrenalina, że ktoś nas zobaczy. Zwykła sypialnia zostawała na te noce, kiedy nocowaliśmy u moich lub jego rodziców. Pewnego letniego popołudnia nie mieliśmy co robić, więc wsiedliśmy do mojego pikaczento i pojechaliśmy się przejechać. Koniec końców wylądowaliśmy na dworcu kolejowym. Jak zwykle naszła nas ochota na drobne igraszki. Odwzorowaliśmy scenę z jednego z polskich seriali komediowych (bodajże &#8220;Chłopaki nie płaczą&#8221;), w którym facet brutalnie bierze dziewczynę od tyłu na masce samochodu. W tej roli wystąpił wtedy Michał Milowicz. Miałam na sobie getry i mini. Po chwili getrów już nie miałam, a Paweł siłował się z gumką. Nie zajęło mu to dużo czasu i moment później już czułam jak we mnie wnika. Bez gry wstępnej. A po co. Gra wstępna była w samochodzie, kiedy ja prowadziłam, a on całował mnie po szyi, schodząc coraz niżej, a moja ręka, zamiast na dźwignię zmiany biegów, wędrowała od zewnętrznej strony jego kolan ku strefie, do której tylko ja miałam dostęp od jakiegoś, dłuższego już czasu. To wystarczyło. Było cudownie.</p>
<p>Kiedy oboje już ochłonęliśmy, postanowiliśmy się jeszcze trochę pobawić. Jako, że od dłuższego czasu nie mieliśmy okazji odwiedzić tutejszego dworca, spędziliśmy tam trochę czasu. Chodziliśmy po ruinach dawnego dworca. Tam gdzie dawniej były kasy biletowe, teraz rósł sobie krzaczek z takimi ciemnymi owocami, podobnymi do jagód. Nie ryzykowaliśmy i nie próbowaliśmy zjeść tych owoców.</p>
<p>Stał tam też pociąg. Kilka wagonów. Pięć, może sześć. Nie zwracaliśmy na to uwagi. Stał tak dosyć długo, a do ostatniego wagonu były przyczepione schodki, po których można było wejść na jego dach. A skoro tak lubiliśmy zabawy, postanowiliśmy wejść na dach jednego z wagonów pociągu i tam się kochać. Jakie było nasze zaskoczenie, kiedy w momencie, gdy On wdrapał się już na samą górę, pociąg ruszył. Ja zostałam na ziemi.</p>
<p>W pierwszej chwili mnie wmurowało i nie wiedziałam co zrobić. Pociąg dopiero nabierał prędkości, więc dość szybko zorientowałam się co się dzieje i zaczęłam biec. Chciałam wyprzedzić pociąg i przekazać jakoś maszyniście, żeby zatrzymał pociąg. On leżał bezładnie na dachu. Niestety nie udało mi się to co miałam w planach i rozpędzona już maszyna dość szybko zniknęła za zakrętem.</p>
<p>Zostałam sama na peronie nie wiedząc co robić. Łzy płynęły mi ciurkiem po policzkach. Próbowałam coś krzyczeć, ale nic to nie dało. Wsiadłam szybko do mojego pikaczento i ile fabryka dała pędziłam do najbliższej stacji, jednak kiedy tam dotarłam zobaczyłam, tylko, że pociąg pojechał dalej. Pośpieszny. Zrobiłam to samo. Jeśli ktoś twierdził, że takim samochodem nie da się zamknąć licznika to muszę go wyprowadzić z błędu, bo grubo się mylił. Dojechałam do Piotrkowa. O dziwo, udało mi się dotrzeć na dworzec przed pociągiem. Nie zamknąwszy nawet samochodu, pobiegłam do budki informacyjnej&#8230; krzyknęłam, że ten pociąg musi się tutaj zatrzymać, po czym wybiegłam szybko na tory. Za mną wybiegło dwóch jakichś facetów. Jeden był ubrany w mundur, ale raczej nie był policjantem. Próbowali ściągnąć mnie z torów. Jednak ja w całej swojej desperacja, pozwoliłam się tylko przesunąć o metr czy dwa, po czym  ich podrapałam i dali mi spokój. Miałam wrażenie, że mijają godziny. Lecz po chwili moim oczom ukazały się światła pociągu. Widziałam już, że zwalnia. Poczułam, że adrenalina, której poziom był już krytycznie wysoki, odpływa gdzieś.</p>
<p>Maszyna zatrzymała się około 10 metrów przede mną. Zeszłam na bok. Po chwili dołączył do mnie trzęsący się jeszcze On. Przytulił się i staliśmy tam tak jeszcze dobrych kilka minut. Ludzie dziwnie się na nas patrzyli, ale kto by zwracał na to uwagę. Nadal przytuleni ruszyliśmy do mojego samochodu. Do naszego samochodu. Wróciliśmy do domu. To popołudnie i ten wieczór długo będziemy pamiętać. I już nigdy nie będziemy próbować wejść na dach pociągu. Jeśli w ogóle jeszcze kiedyś do takiego się któreś z nas zbliży. <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[ggplot2 Version of Figures in "Lattice: Multivariate Data Visualization with R" (Part 12)]]></title>
<link>http://learnr.wordpress.com/2009/08/18/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-13/</link>
<pubDate>Tue, 18 Aug 2009 12:48:59 +0000</pubDate>
<dc:creator>learnr</dc:creator>
<guid>http://learnr.wordpress.com/2009/08/18/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-13/</guid>
<description><![CDATA[This is the 12th post in a series attempting to recreate the figures in Lattice: Multivariate Data V]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>This is the 12th post in a series attempting to recreate the figures in <a href="http://www.amazon.com/Lattice-Multivariate-Data-Visualization-Use/dp/0387759689/">Lattice: Multivariate Data Visualization with R</a> (R code available <a href="http://lmdvr.r-forge.r-project.org/figures/figures.html">here</a>) with <a href="http://had.co.nz/ggplot2">ggplot2</a>.</p>
<p>Previous parts in this series: <a href="http://learnr.wordpress.com/2009/06/28/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-1/">Part 1</a>, <a href="http://learnr.wordpress.com/2009/06/29/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-2/">Part 2</a>, <a href="http://learnr.wordpress.com/2009/07/02/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-3/">Part 3</a>, <a href="http://learnr.wordpress.com/2009/07/02/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-4/">Part 4</a>, <a href="http://learnr.wordpress.com/2009/07/15/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-5/">Part 5</a>, <a href="http://learnr.wordpress.com/2009/07/20/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-6/">Part 6</a>, <a href="http://learnr.wordpress.com/2009/07/27/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-7/">Part 7</a>, <a href="http://learnr.wordpress.com/2009/08/03/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-8/">Part 8</a>, <a href="http://learnr.wordpress.com/2009/08/10/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-9/">Part 9</a>, <a href="http://learnr.wordpress.com/2009/08/11/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-10/">Part 10</a>, <a href="http://learnr.wordpress.com/2009/08/13/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-11/">Part 11</a>.</p>
<hr />
<h2><a name="_chapter_13_advanced_panel_functions"></a>Chapter 13 &#8211; Advanced Panel Functions</h2>
<p><b>Topics covered:</b></p>
<ul>
<li> Built-in panel and accessors functions </li>
<li> Examples </li>
</ul>
<p> <!--more--><br />
<h3><a name="_figure_13_1"></a>Figure 13.1</h3>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; library(lattice)
&#62; library(ggplot2)</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; grid &#60;- data.frame(p = 11:30, q = 10)
&#62; grid$k &#60;- with(grid, factor(p/q))</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; panel.hypotrochoid &#60;- function(r, d, cycles = 10, density = 30) {
+     if (missing(r))
+         r &#60;- runif(1, 0.25, 0.75)
+     if (missing(d))
+         d &#60;- runif(1, 0.25 * r, r)
+     t &#60;- 2 * pi * seq(0, cycles, by = 1/density)
+     x &#60;- (1 - r) * cos(t) + d * cos((1 - r) * t/r)
+     y &#60;- (1 - r) * sin(t) - d * sin((1 - r) * t/r)
+     panel.lines(x, y)
+ }
&#62; panel.hypocycloid &#60;- function(x, y, cycles = x, density = 30) {
+     panel.hypotrochoid(r = x/y, d = x/y, cycles = cycles,
+         density = density)
+ }
&#62; prepanel.hypocycloid &#60;- function(x, y) {
+     list(xlim = c(-1, 1), ylim = c(-1, 1))
+ }</pre>
</td>
</tr>
</table>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- xyplot(p ~ q &#124; k, grid, aspect = 1, scales = list(draw = FALSE),
+     prepanel = prepanel.hypocycloid, panel = panel.hypocycloid)
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; panel.hypotrochoid.gg &#60;- function(r, d, cycles = 10,
+     density = 30) {
+     if (missing(r))
+         r &#60;- runif(1, 0.25, 0.75)
+     if (missing(d))
+         d &#60;- runif(1, 0.25 * r, r)
+     t &#60;- 2 * pi * seq(0, cycles, by = 1/density)
+     x &#60;- (1 - r) * cos(t) + d * cos((1 - r) * t/r)
+     y &#60;- (1 - r) * sin(t) - d * sin((1 - r) * t/r)
+     data.frame(x, y)
+ }
&#62; panel.hypocycloid.gg &#60;- function(x, y, cycles = x, density = 30) {
+     panel.hypotrochoid.gg(r = x/y, d = x/y, cycles = cycles,
+         density = density)
+ }</pre>
</td>
</tr>
</table>
<table style="margin:.2em 0;">
<tr valign="top">
<td style="padding:.5em;">
<p><b><u>Note</u></b></p>
</td>
<td style="border-left:3px solid #e8e8e8;padding:.5em;"><tt>panel.lines(x, y)</tt> replaced with <tt>data.frame(x, y)</tt> in the <tt>panel.hypotrochoid.gg</tt> function.</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; df &#60;- ddply(grid, .(p, q, k), function(df) {
+     with(df, panel.hypocycloid.gg(q, p))
+ })</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(df, aes(x, y)) + geom_path() + facet_wrap(~k,
+     ncol = 4) + scale_x_continuous("", breaks = NA) +
+     scale_y_continuous("", breaks = NA)
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter13-13_01_l2.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter13-13_01_l_small2.png" style="border-width:0;" alt="chapter13-13_01_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter13-13_01_r2.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter13-13_01_r_small2.png" style="border-width:0;" alt="chapter13-13_01_r_small.png"> </a></p>
<h3><a name="_figure_13_2"></a>Figure 13.2</h3>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; set.seed(20070706)</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- xyplot(c(-1, 1) ~ c(-1, 1), aspect = 1, cycles = 15,
+     scales = list(draw = FALSE), xlab = "", ylab = "",
+     panel = panel.hypotrochoid)
&#62; print(pl[rep(1, 42)])</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; df2 &#60;- ldply(rep(1:42), function(k) {
+     data.frame(k, panel.hypotrochoid.gg(cycles = 15))
+ })</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(df2, aes(x, y)) + geom_path() + facet_wrap(~k,
+     ncol = 6) + scale_x_continuous("", breaks = NA) +
+     scale_y_continuous("", breaks = NA) + opts(panel.margin = 0,
+     strip.text.x = theme_blank())
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter13-13_02_l2.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter13-13_02_l_small1.png" style="border-width:0;" alt="chapter13-13_02_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter13-13_02_r1.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter13-13_02_r_small1.png" style="border-width:0;" alt="chapter13-13_02_r_small.png"> </a></p>
<h3><a name="_figure_13_3"></a>Figure 13.3</h3>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; library("logspline")</pre>
</td>
</tr>
</table>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; prepanel.ls &#60;- function(x, n = 50, ...) {
+     fit &#60;- logspline(x)
+     xx &#60;- do.breaks(range(x), n)
+     yy &#60;- dlogspline(xx, fit)
+     list(ylim = c(0, max(yy)))
+ }
&#62; panel.ls &#60;- function(x, n = 50, ...) {
+     fit &#60;- logspline(x)
+     xx &#60;- do.breaks(range(x), n)
+     yy &#60;- dlogspline(xx, fit)
+     panel.lines(xx, yy, ...)
+ }</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; faithful$Eruptions &#60;- equal.count(faithful$eruptions,
+     4)</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- densityplot(~waiting &#124; Eruptions, data = faithful,
+     prepanel = prepanel.ls, panel = panel.ls)
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; fn &#60;- function(data = faithful$eruptions, number = 4,
+     ...) {
+     intrv &#60;&#60;- as.data.frame(co.intervals(data, number,
+         ...))
+     eruptions &#60;- sort(unique(data))
+     intervals &#60;- ldply(eruptions, function(x) {
+         t(as.numeric(x &#60; intrv$V2 &#38; x &#62; intrv$V1))
+     })
+     tmp &#60;- melt(cbind(eruptions, intervals), id.var = 1)
+     tmp[tmp$value &#62; 0, 1:2]
+ }
&#62; faithful2 &#60;- merge(faithful, fn())
&#62; intrv &#60;- with(intrv, paste(V1, V2, sep = "-"))
&#62; faithful2 &#60;- rename(faithful2, c(variable = "erupt"))
&#62; faithful2$erupt &#60;- factor(faithful2$erupt, labels = intrv)</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; panel.ls.gg &#60;- function(x, n = 50, ...) {
+     fit &#60;- logspline(x)
+     xx &#60;- do.breaks(range(x), n)
+     yy &#60;- dlogspline(xx, fit)
+     data.frame(xx, yy, ...)
+ }
&#62; a &#60;- ddply(faithful2, .(erupt), function(df) {
+     panel.ls.gg(df$waiting)
+ })</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(a, aes(xx, yy)) + geom_line() + facet_grid(~erupt)
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter13-13_03_l1.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter13-13_03_l_small1.png" style="border-width:0;" alt="chapter13-13_03_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter13-13_03_r1.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter13-13_03_r_small1.png" style="border-width:0;" alt="chapter13-13_03_r_small.png"> </a></p>
<h3><a name="_figure_13_4"></a>Figure 13.4</h3>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; data(Chem97, package = "mlmRev")</pre>
</td>
</tr>
</table>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; panel.bwtufte &#60;- function(x, y, coef = 1.5, ...) {
+     x &#60;- as.numeric(x)
+     y &#60;- as.numeric(y)
+     ux &#60;- sort(unique(x))
+     blist &#60;&#60;- tapply(y, factor(x, levels = ux), boxplot.stats,
+         coef = coef, do.out = FALSE)
+     blist.stats &#60;&#60;- t(sapply(blist, "[[", "stats"))
+     blist.out &#60;&#60;- lapply(blist, "[[", "out")
+     panel.points(y = blist.stats[, 3], x = ux, pch = 16,
+         ...)
+     panel.segments(x0 = rep(ux, 2), y0 = c(blist.stats[,
+         1], blist.stats[, 5]), x1 = rep(ux, 2), y1 = c(blist.stats[,
+         2], blist.stats[, 4]), ...)
+ }</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- bwplot(gcsescore^2.34 ~ gender &#124; factor(score),
+     Chem97, panel = panel.bwtufte, layout = c(6, 1),
+     ylab = "Transformed GCSE score")
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; dt &#60;- ddply(Chem97, .(gender, score), function(df) {
+     boxplot.stats(df$gcsescore^2.34)$stats
+ })</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(dt, aes(x = gender)) + geom_linerange(aes(ymin = V1,
+     ymax = V2)) + geom_linerange(aes(ymin = V4, ymax = V5)) +
+     geom_point(aes(y = V3)) + facet_grid(~score)
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter13-13_04_l1.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter13-13_04_l_small1.png" style="border-width:0;" alt="chapter13-13_04_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter13-13_04_r1.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter13-13_04_r_small1.png" style="border-width:0;" alt="chapter13-13_04_r_small.png"> </a></p>
<h3><a name="_figure_13_5"></a>Figure 13.5</h3>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; data(Cars93, package = "MASS")
&#62; cor.Cars93 &#60;- cor(Cars93[, !sapply(Cars93, is.factor)],
+     use = "pair")
&#62; ord &#60;- order.dendrogram(as.dendrogram(hclust(dist(cor.Cars93))))
&#62; panel.corrgram &#60;- function(x, y, z, subscripts, at, level = 0.9,
+     label = FALSE, ...) {
+     require("ellipse", quietly = TRUE)
+     x &#60;- as.numeric(x)[subscripts]
+     y &#60;- as.numeric(y)[subscripts]
+     z &#60;- as.numeric(z)[subscripts]
+     zcol &#60;- level.colors(z, at = at, ...)
+     for (i in seq(along = z)) {
+         ell &#60;- ellipse(z[i], level = level, npoints = 50,
+             scale = c(0.2, 0.2), centre = c(x[i], y[i]))
+         panel.polygon(ell, col = zcol[i], border = zcol[i],
+             ...)
+     }
+     if (label)
+         panel.text(x = x, y = y, lab = 100 * round(z,
+             2), cex = 0.8, col = ifelse(z &#60; 0, "white",
+             "black"))
+ }</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- levelplot(cor.Cars93[ord, ord], at = do.breaks(c(-1.01,
+     1.01), 20), xlab = NULL, ylab = NULL, colorkey = list(space = "top"),
+     scales = list(x = list(rot = 90)), panel = panel.corrgram,
+     label = TRUE)
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">Ellipses are not supported in ggplot2.</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter13-13_05_l1.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter13-13_05_l_small1.png" style="border-width:0;" alt="chapter13-13_05_l_small.png"> </a></p>
<h3><a name="_figure_13_6"></a>Figure 13.6</h3>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; panel.corrgram.2 &#60;- function(x, y, z, subscripts, at = pretty(z),
+     scale = 0.8, ...) {
+     require("grid", quietly = TRUE)
+     x &#60;- as.numeric(x)[subscripts]
+     y &#60;- as.numeric(y)[subscripts]
+     z &#60;- as.numeric(z)[subscripts]
+     zcol &#60;- level.colors(z, at = at, ...)
+     for (i in seq(along = z)) {
+         lims &#60;- range(0, z[i])
+         tval &#60;- 2 * base::pi * seq(from = lims[1], to = lims[2],
+             by = 0.01)
+         grid.polygon(x = x[i] + 0.5 * scale * c(0, sin(tval)),
+             y = y[i] + 0.5 * scale * c(0, cos(tval)),
+             default.units = "native", gp = gpar(fill = zcol[i]))
+         grid.circle(x = x[i], y = y[i], r = 0.5 * scale,
+             default.units = "native")
+     }
+ }</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- levelplot(cor.Cars93[ord, ord], xlab = NULL, ylab = NULL,
+     at = do.breaks(c(-1.01, 1.01), 101), panel = panel.corrgram.2,
+     scales = list(x = list(rot = 90)), colorkey = list(space = "top"),
+     col.regions = colorRampPalette(c("red", "white",
+         "blue")))
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">Not supported in +ggplot2+.</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/rplot0011.png"> <img src="http://learnr.files.wordpress.com/2009/08/rplot001_small1.png" style="border-width:0;" alt="Rplot001_small.png"> </a></p>
<h3><a name="_figure_13_7"></a>Figure 13.7</h3>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; panel.3d.contour &#60;- function(x, y, z, rot.mat, distance,
+     nlevels = 20, zlim.scaled, ...) {
+     add.line &#60;- trellis.par.get("add.line")
+     panel.3dwire(x, y, z, rot.mat, distance, zlim.scaled = zlim.scaled,
+         ...)
+     clines &#60;- contourLines(x, y, matrix(z, nrow = length(x),
+         byrow = TRUE), nlevels = nlevels)
+     for (ll in clines) {
+         m &#60;- ltransform3dto3d(rbind(ll$x, ll$y, zlim.scaled[2]),
+             rot.mat, distance)
+         panel.lines(m[1, ], m[2, ], col = add.line$col,
+             lty = add.line$lty, lwd = add.line$lwd)
+     }
+ }</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- wireframe(volcano, zlim = c(90, 250), nlevels = 10,
+     aspect = c(61/87, 0.3), panel.aspect = 0.6, panel.3d.wireframe = "panel.3d.contour",
+     shade = TRUE, screen = list(z = 20, x = -60))
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">ggplot2 currently does not support true 3d surfaces.</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter13-13_07_l1.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter13-13_07_l_small1.png" style="border-width:0;" alt="chapter13-13_07_l_small.png"> </a></p>
<h3><a name="_figure_13_8"></a>Figure 13.8</h3>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; library("maps")
&#62; county.map &#60;- map("county", plot = FALSE, fill = TRUE)</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; data(ancestry, package = "latticeExtra")
&#62; ancestry &#60;- subset(ancestry, !duplicated(county))
&#62; rownames(ancestry) &#60;- ancestry$county
&#62; freq &#60;- table(ancestry$top)
&#62; keep &#60;- names(freq)[freq &#62; 10]
&#62; ancestry$mode &#60;- with(ancestry, factor(ifelse(top %in%
+     keep, top, "Other")))
&#62; modal.ancestry &#60;- ancestry[county.map$names, "mode"]</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; library("RColorBrewer")
&#62; colors &#60;- brewer.pal(n = nlevels(ancestry$mode), name = "Pastel1")</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- xyplot(y ~ x, county.map, aspect = "iso", scales = list(draw = FALSE),
+     xlab = "", ylab = "", par.settings = list(axis.line = list(col = "transparent")),
+     col = colors[modal.ancestry], border = NA, panel = panel.polygon,
+     key = list(text = list(levels(modal.ancestry), adj = 1),
+         rectangles = list(col = colors), x = 1, y = 0,
+         corner = c(1, 0)))
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; counties &#60;- map_data("county")
&#62; counties$reg &#60;- with(counties, paste(region, subregion,
+     sep = ","))
&#62; co_anc &#60;- merge(counties, ancestry, by.x = "reg", by.y = "county")
&#62; co_anc &#60;- co_anc[order(co_anc$order), ]</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(co_anc, aes(long, lat, fill = mode, group = group)) +
+     geom_polygon() + scale_fill_brewer("", palette = "Pastel1")
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter13-13_08_l1.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter13-13_08_l_small1.png" style="border-width:0;" alt="chapter13-13_08_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter13-13_08_r1.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter13-13_08_r_small1.png" style="border-width:0;" alt="chapter13-13_08_r_small.png"> </a></p>
<h3><a name="_figure_13_9"></a>Figure 13.9</h3>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; rad &#60;- function(x) {
+     pi * x/180
+ }
&#62; county.map$xx &#60;- with(county.map, cos(rad(x)) * cos(rad(y)))
&#62; county.map$yy &#60;- with(county.map, sin(rad(x)) * cos(rad(y)))
&#62; county.map$zz &#60;- with(county.map, sin(rad(y)))
&#62; panel.3dpoly &#60;- function(x, y, z, rot.mat = diag(4),
+     distance, ...) {
+     m &#60;- ltransform3dto3d(rbind(x, y, z), rot.mat, distance)
+     panel.polygon(x = m[1, ], y = m[2, ], ...)
+ }
&#62; aspect &#60;- with(county.map, c(diff(range(yy, na.rm = TRUE)),
+     diff(range(zz, na.rm = TRUE)))/diff(range(xx, na.rm = TRUE)))</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- cloud(zz ~ xx * yy, county.map, par.box = list(col = "grey"),
+     aspect = aspect, panel.aspect = 0.6, lwd = 0.01,
+     panel.3d.cloud = panel.3dpoly, col = colors[modal.ancestry],
+     screen = list(z = 10, x = -30), key = list(text = list(levels(modal.ancestry),
+         adj = 1), rectangles = list(col = colors), space = "top",
+         columns = 4), scales = list(draw = FALSE), zoom = 1.1,
+     xlab = "", ylab = "", zlab = "")
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">ggplot2 currently does not support true 3d surfaces.</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter13-13_09_l1.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter13-13_09_l_small1.png" style="border-width:0;" alt="chapter13-13_09_l_small.png"> </a></p>
<h3><a name="_figure_13_10"></a>Figure 13.10</h3>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; library("latticeExtra")
&#62; library("mapproj")
&#62; data(USCancerRates)
&#62; rng &#60;- with(USCancerRates, range(rate.male, rate.female,
+     finite = TRUE))
&#62; nbreaks &#60;- 50
&#62; breaks &#60;- exp(do.breaks(log(rng), nbreaks))
&#62; breaks2 &#60;- c(unique(breaks[1 + (0:(nbreaks - 1)%/%10) *
+     10]), max(breaks) - 0.1)</pre>
</td>
</tr>
</table>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- mapplot(rownames(USCancerRates) ~ rate.male + rate.female,
+     data = USCancerRates, breaks = breaks, map = map("county",
+         plot = FALSE, fill = TRUE, projection = "tetra"),
+     scales = list(draw = T), xlab = "", main = "Average yearly deaths due to cancer per 100000")
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; USCancerRates.df &#60;- namerows(USCancerRates, col.name = "reg")
&#62; co_cancer &#60;- merge(counties, USCancerRates.df, by = c("reg"))
&#62; co_cancer &#60;- co_cancer[order(co_cancer$order), ]
&#62; co_cancer.m &#60;- melt(co_cancer, measure.vars = c("rate.male",
+     "rate.female"), na.rm = TRUE)
&#62; co_cancer.m$fill &#60;- with(co_cancer.m, as.numeric(as.character(cut(value,
+     breaks, labels = comma(breaks[-1])))))</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; brewer.div &#60;- colorRampPalette(brewer.pal(11, "Spectral"))</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(co_cancer.m, aes(long, lat, group = reg,
+     fill = fill)) + geom_polygon() + coord_map(projection = "tetra") +
+     facet_wrap(~variable, ncol = 1) + scale_fill_gradientn("",
+     colours = brewer.div(nbreaks), trans = "log") + opts(title = "Average yearly deaths due to cancer per 100000")
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter13-13_10_l1.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter13-13_10_l_small1.png" style="border-width:0;" alt="chapter13-13_10_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter13-13_10_r1.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter13-13_10_r_small1.png" style="border-width:0;" alt="chapter13-13_10_r_small.png"> </a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Srarytety...]]></title>
<link>http://dzokero.wordpress.com/2009/08/18/srarytety/</link>
<pubDate>Tue, 18 Aug 2009 09:46:45 +0000</pubDate>
<dc:creator>dzokero</dc:creator>
<guid>http://dzokero.wordpress.com/2009/08/18/srarytety/</guid>
<description><![CDATA[Projekt ustawy o parytecie gotowy. Połowę miejsc na listach wyborczych mają zajmować kobiety. A jeśl]]></description>
<content:encoded><![CDATA[Projekt ustawy o parytecie gotowy. Połowę miejsc na listach wyborczych mają zajmować kobiety. A jeśl]]></content:encoded>
</item>
<item>
<title><![CDATA[Spowiedź...]]></title>
<link>http://polskihomik.wordpress.com/2009/08/15/spowiedz/</link>
<pubDate>Sat, 15 Aug 2009 14:53:26 +0000</pubDate>
<dc:creator>Hercules</dc:creator>
<guid>http://polskihomik.wordpress.com/2009/08/15/spowiedz/</guid>
<description><![CDATA[Ta opowieść, która będzie się ciągnęła przez wszystkie wpisy na tym blogu, jest moją spowiedzią. Móg]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Ta opowieść, która będzie się ciągnęła przez wszystkie wpisy na tym blogu, jest moją spowiedzią.</p>
<p>Mógłbym powiedzieć, patrzcie i uczcie się na moich grzechach. Ale nie powiem tego, gdyż homoseksualizm nie jest złem.</p>
<p>Wiem jedno o spowiedziach.</p>
<p>Są <span style="font-weight:bold;"><span style="color:#ff0000;">Anonimowe</span>. </span></p>
<p>Dlatego nazwijcie mnie Herculesem.</p>
<p>Cała ta historia zaczęła się wiele lat temu, dokładnie 21 marca 1950r. W dniu gdy przyszedłem na świat.</p>
<p>Homoseksualistą byłem zawsze. Wtedy gdy bawiłem się z innymi w piaskownicy, wtedy gdy wsiadałem na swój pierwszy rower, wtedy gdy zdawałem maturę, wtedy gdy brałem ślub z &#8220;miłością mojego życia&#8221;, wtedy gdy asystowałem przy narodzinach mojej córki i wtedy gdy rozwodziłem się.</p>
<p>Tak, dobrze czytasz. Miałem żonę. Mam córkę.</p>
<p>Ożeniłem się 30 grudnia 1991r. Byłem 41-latkiem, a jeszcze nie miałem pewności kim jestem. Oczywiście, wcześniej  w moim życiu było kilka epizodów związanych z mężczyznami.<br />
Przelotny seks lub dłuższe związki, ale gdy poznałem domniemaną &#8220;miłość mojego życia&#8221;, wszystko się zmieniło. Myślałem, że &#8220;istnienie facetów w moim życiu uczuciowym&#8221; było błędem, zwykłą pomyłką.</p>
<p>Rok później, miałem już zupełnie inne zdanie o mojej żonie. Wiedziałem,  iż preferuję mężczyzn, że to oni mnie podniecają, że to z nimi chcę uprawiać seks, że to z jednym z nich chcę spędzić resztę swojego życia. Niestety (a może &#8220;stety&#8221;) dziecko było już w drodze. Postanowiłem odczekać czas do narodzin.</p>
<p>Gosia urodziła się dokładnie 26 maja 1992r.</p>
<p>Pół roku później było już po rozwodzie.</p>
<p>W 1993r. poznałem mojego obecnego faceta, razem jesteśmy od sierpnia 1994r. Ma na imię Daniel, jest młodszy o 14 lat,  moją córkę traktuje tak jak by była i jego dzieckiem.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[ggplot2 Version of Figures in "Lattice: Multivariate Data Visualization with R" (Part 11)]]></title>
<link>http://learnr.wordpress.com/2009/08/13/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-11/</link>
<pubDate>Thu, 13 Aug 2009 09:00:48 +0000</pubDate>
<dc:creator>learnr</dc:creator>
<guid>http://learnr.wordpress.com/2009/08/13/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-11/</guid>
<description><![CDATA[This is the 11th post in a series attempting to recreate the figures in Lattice: Multivariate Data V]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>This is the 11th post in a series attempting to recreate the figures in <a href="http://www.amazon.com/Lattice-Multivariate-Data-Visualization-Use/dp/0387759689/">Lattice: Multivariate Data Visualization with R</a> (R code available <a href="http://lmdvr.r-forge.r-project.org/figures/figures.html">here</a>) with <a href="http://had.co.nz/ggplot2">ggplot2</a>.</p>
<p>Previous parts in this series: <a href="http://learnr.wordpress.com/2009/06/28/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-1/">Part 1</a>, <a href="http://learnr.wordpress.com/2009/06/29/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-2/">Part 2</a>, <a href="http://learnr.wordpress.com/2009/07/02/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-3/">Part 3</a>, <a href="http://learnr.wordpress.com/2009/07/02/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-4/">Part 4</a>, <a href="http://learnr.wordpress.com/2009/07/15/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-5/">Part 5</a>, <a href="http://learnr.wordpress.com/2009/07/20/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-6/">Part 6</a>, <a href="http://learnr.wordpress.com/2009/07/27/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-7/">Part 7</a>, <a href="http://learnr.wordpress.com/2009/08/03/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-8/">Part 8</a>, <a href="http://learnr.wordpress.com/2009/08/10/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-9/">Part 9</a>, <a href="http://learnr.wordpress.com/2009/08/11/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-10/">Part 10</a>.</p>
<hr />
<h2><a name="_chapter_11_manipulating_the_trellis_object"></a>Chapter 11 &#8211; Manipulating the &#8220;trellis&#8221; object</h2>
<p><b>Topics covered:</b></p>
<ul>
<li> Methods for &#8220;trellis&#8221; objects </li>
<li> Tukey mean-difference plot </li>
<li> Other specialized manipulations </li>
</ul>
<p> <!--more--><br />
<h3><a name="_figure_11_1"></a>Figure 11.1</h3>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; library(lattice)
&#62; library(ggplot2)</pre>
</td>
</tr>
</table>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; dp.uspe &#60;- dotplot(t(USPersonalExpenditure), groups = FALSE,
+     index.cond = function(x, y) median(x), layout = c(1,
+         5), type = c("p", "h"), xlab = "Expenditure (billion dollars)")
&#62; dp.uspe.log &#60;- dotplot(t(USPersonalExpenditure), groups = FALSE,
+     index.cond = function(x, y) median(x), layout = c(1,
+         5), scales = list(x = list(log = 2)), xlab = "Expenditure (billion dollars)")
&#62; plot(dp.uspe, split = c(1, 1, 2, 1), more = TRUE)
&#62; plot(dp.uspe.log, split = c(2, 1, 2, 1), more = FALSE)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; library(ggextra)</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; p &#60;- ggplot(melt(USPersonalExpenditure), aes(X2, value,
+     ymin = 0, ymax = value)) + geom_point() + coord_flip() +
+     facet_wrap(~X1, ncol = 1) + ylab("Expenditure (billion dollars)")
&#62; p1 &#60;- p + geom_linerange()
&#62; p2 &#60;- p + scale_y_log2()
&#62; print(arrange(p1, p2))</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter11-11_01_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter11-11_01_l_small1.png" style="border-width:0;" alt="chapter11-11_01_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter11-11_01_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter11-11_01_r_small1.png" style="border-width:0;" alt="chapter11-11_01_r_small.png"> </a></p>
<h3><a name="_figure_11_2"></a>Figure 11.2</h3>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; state &#60;- data.frame(state.x77, state.region, state.name)
&#62; state$state.name &#60;- with(state, reorder(reorder(state.name,
+     Frost), as.numeric(state.region)))</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; dpfrost &#60;- dotplot(state.name ~ Frost &#124; reorder(state.region,
+     Frost), data = state, layout = c(1, 4), scales = list(y = list(relation = "free")))
&#62; plot(dpfrost, panel.height = list(x = c(16, 13, 9, 12),
+     unit = "null"))</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; state$state.region &#60;- with(state, reorder(state.region,
+     Frost))</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(state, aes(Frost, state.name)) + geom_point() +
+     facet_grid(state.region ~ ., scales = "free_y", space = "free",
+         as.table = F)
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter11-11_02_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter11-11_02_l_small1.png" style="border-width:0;" alt="chapter11-11_02_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter11-11_02_r1.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter11-11_02_r_small1.png" style="border-width:0;" alt="chapter11-11_02_r_small.png"> </a></p>
<h3><a name="_figure_11_3"></a>Figure 11.3</h3>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; plot(dpfrost, panel.height = list(x = c(16, 13, 9, 12),
+     unit = "null"))
&#62; print(update(trellis.last.object(), layout = c(1, 1))[2])</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- pg %+% subset(state, state.region == "West") +
+     facet_wrap(~state.region, scales = "free_y")
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter11-11_03_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter11-11_03_l_small1.png" style="border-width:0;" alt="chapter11-11_03_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter11-11_03_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter11-11_03_r_small1.png" style="border-width:0;" alt="chapter11-11_03_r_small.png"> </a></p>
<h3><a name="_figure_11_4"></a>Figure 11.4</h3>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; npanel &#60;- 12
&#62; rot &#60;- list(z = seq(0, 30, length = npanel), x = seq(0,
+     -80, length = npanel))
&#62; quakeLocs &#60;- cloud(depth ~ long + lat, quakes, pch = ".",
+     cex = 1.5, panel = function(..., screen) {
+         pn &#60;- panel.number()
+         panel.cloud(..., screen = list(z = rot$z[pn],
+             x = rot$x[pn]))
+     }, xlab = NULL, ylab = NULL, zlab = NULL, scales = list(draw = FALSE),
+     zlim = c(690, 30), par.settings = list(axis.line = list(col = "transparent")))
&#62; pl &#60;- quakeLocs[rep(1, npanel)]
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">True 3d not supported in ggplot2.</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter11-11_04_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter11-11_04_l_small1.png" style="border-width:0;" alt="chapter11-11_04_l_small.png"> </a></p>
<h3><a name="_figure_11_5"></a>Figure 11.5</h3>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; data(Chem97, package = "mlmRev")</pre>
</td>
</tr>
</table>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; ChemQQ &#60;- qq(gender ~ gcsescore &#124; factor(score), Chem97,
+     f.value = ppoints(100), strip = strip.custom(style = 5))
&#62; pl &#60;- tmd(ChemQQ)
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; q &#60;- function(x, probs = ppoints(100)) {
+     data.frame(q = probs, value = quantile(x, probs))
+ }
&#62; Chem97.q &#60;- ddply(Chem97, c("gender", "score"), function(df) q(df$gcsescore))
&#62; Chem97.df &#60;- recast(Chem97.q, score + q ~ gender, id.var = 1:3)</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(Chem97.df, aes(M, F)) + geom_point(aes(x = (M +
+     F)/2, y = F - M)) + facet_wrap(~score) + xlab("mean") +
+     ylab("difference")
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter11-11_05_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter11-11_05_l_small1.png" style="border-width:0;" alt="chapter11-11_05_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter11-11_05_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter11-11_05_r_small1.png" style="border-width:0;" alt="chapter11-11_05_r_small.png"> </a></p>
<h3><a name="_figure_11_6"></a>Figure 11.6</h3>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; library("latticeExtra")
&#62; data(biocAccess)</pre>
</td>
</tr>
</table>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; baxy &#60;- xyplot(log10(counts) ~ hour &#124; month + weekday,
+     biocAccess, type = c("p", "a"), as.table = TRUE,
+     pch = ".", cex = 2, col.line = "black")
&#62; dimnames(baxy)$month &#60;- month.name[1:5]
&#62; pl &#60;- useOuterStrips(baxy)
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(biocAccess, aes(hour, log10(counts))) +
+     geom_point(colour = "steelblue", size = 1) + geom_line(stat = "summary",
+     fun.y = mean) + facet_grid(weekday ~ month)
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter11-11_06_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter11-11_06_l_small1.png" style="border-width:0;" alt="chapter11-11_06_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter11-11_06_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter11-11_06_r_small1.png" style="border-width:0;" alt="chapter11-11_06_r_small.png"> </a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[ggplot2 Version of Figures in "Lattice: Multivariate Data Visualization with R" (Part 10)]]></title>
<link>http://learnr.wordpress.com/2009/08/11/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-10/</link>
<pubDate>Tue, 11 Aug 2009 12:00:27 +0000</pubDate>
<dc:creator>learnr</dc:creator>
<guid>http://learnr.wordpress.com/2009/08/11/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-10/</guid>
<description><![CDATA[This is the 10th post in a series attempting to recreate the figures in Lattice: Multivariate Data V]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>This is the 10th post in a series attempting to recreate the figures in <a href="http://www.amazon.com/Lattice-Multivariate-Data-Visualization-Use/dp/0387759689/">Lattice: Multivariate Data Visualization with R</a> (R code available <a href="http://lmdvr.r-forge.r-project.org/figures/figures.html">here</a>) with <a href="http://had.co.nz/ggplot2">ggplot2</a>.</p>
<p>Previous parts in this series: <a href="http://learnr.wordpress.com/2009/06/28/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-1/">Part 1</a>, <a href="http://learnr.wordpress.com/2009/06/29/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-2/">Part 2</a>, <a href="http://learnr.wordpress.com/2009/07/02/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-3/">Part 3</a>, <a href="http://learnr.wordpress.com/2009/07/02/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-4/">Part 4</a>, <a href="http://learnr.wordpress.com/2009/07/15/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-5/">Part 5</a>, <a href="http://learnr.wordpress.com/2009/07/20/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-6/">Part 6</a>, <a href="http://learnr.wordpress.com/2009/07/27/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-7/">Part 7</a>, <a href="http://learnr.wordpress.com/2009/08/03/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-8/">Part 8</a>, <a href="http://learnr.wordpress.com/2009/08/10/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-9/">Part 9</a>.</p>
<hr />
<h2><a name="_chapter_10_data_manipulation_and_related_topics"></a>Chapter 10 &#8211; Data Manipulation and Related Topics</h2>
<p><b>Topics covered:</b></p>
<ul>
<li> Non-standard evaluation in the context of lattice </li>
<li> The extended formula interface </li>
<li> Combining data sources, subsetting </li>
<li> Shingles </li>
<li> Ordering levels of categorical variables </li>
<li> Controlling the appearance of strips </li>
</ul>
<p> <!--more--><br />
<h3><a name="_figure_10_1"></a>Figure 10.1</h3>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; library(lattice)
&#62; library(ggplot2)</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; Titanic1 &#60;- as.data.frame(as.table(Titanic[, , "Adult",
+     ]))</pre>
</td>
</tr>
</table>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- barchart(Class ~ Freq &#124; Sex, Titanic1, groups = Survived,
+     stack = TRUE, auto.key = list(title = "Survived",
+         columns = 2))
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(Titanic1, aes(Class, Freq, fill = Survived)) +
+     geom_bar(stat = "identity") + coord_flip() + facet_grid(~Sex)
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_01_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_01_l_small1.png" style="border-width:0;" alt="chapter10-10_01_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_01_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_01_r_small1.png" style="border-width:0;" alt="chapter10-10_01_r_small.png"> </a></p>
<h3><a name="_figure_10_2"></a>Figure 10.2</h3>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; Titanic2 &#60;- reshape(Titanic1, direction = "wide", v.names = "Freq",
+     idvar = c("Class", "Sex"), timevar = "Survived")
&#62; names(Titanic2) &#60;- c("Class", "Sex", "Dead", "Alive")</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- barchart(Class ~ Dead + Alive &#124; Sex, Titanic2,
+     stack = TRUE, auto.key = list(columns = 2))
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(Titanic1, aes(Class, Freq, fill = Survived)) +
+     geom_bar(stat = "identity") + coord_flip() + facet_grid(~Sex) +
+     scale_fill_discrete("", labels = c("Dead", "Alive"))
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_02_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_02_l_small1.png" style="border-width:0;" alt="chapter10-10_02_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_02_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_02_r_small1.png" style="border-width:0;" alt="chapter10-10_02_r_small.png"> </a></p>
<h3><a name="_figure_10_3"></a>Figure 10.3</h3>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; data(Gcsemv, package = "mlmRev")</pre>
</td>
</tr>
</table>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- xyplot(written ~ course &#124; gender, data = Gcsemv,
+     type = c("g", "p", "smooth"), xlab = "Coursework score",
+     ylab = "Written exam score", panel = function(x,
+         y, ...) {
+         panel.xyplot(x, y, ...)
+         panel.rug(x = x[is.na(y)], y = y[is.na(x)])
+     })
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(Gcsemv, aes(course, written)) + geom_point() +
+     geom_smooth(method = "loess", se = F) + geom_rug() +
+     facet_grid(~gender) + xlab("Coursework score") +
+     ylab("Written exam score")
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_03_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_03_l_small1.png" style="border-width:0;" alt="chapter10-10_03_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_03_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_03_r_small1.png" style="border-width:0;" alt="chapter10-10_03_r_small.png"> </a></p>
<h3><a name="_figure_10_4"></a>Figure 10.4</h3>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- qqmath(~written + course, Gcsemv, type = c("p",
+     "g"), outer = TRUE, groups = gender, auto.key = list(columns = 2),
+     f.value = ppoints(200), ylab = "Score")
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(melt(Gcsemv, id.vars = 1:3, na.rm = TRUE)) +
+     geom_point(aes(sample = value, colour = gender),
+         stat = "qq", quantiles = ppoints(200)) + facet_grid(~variable)
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_04_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_04_l_small1.png" style="border-width:0;" alt="chapter10-10_04_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_04_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_04_r_small1.png" style="border-width:0;" alt="chapter10-10_04_r_small.png"> </a></p>
<h3><a name="_figure_10_5"></a>Figure 10.5</h3>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; set.seed(20051028)
&#62; x1 &#60;- rexp(2000)
&#62; x1 &#60;- x1[x1 &#62; 1]
&#62; x2 &#60;- rexp(1000)</pre>
</td>
</tr>
</table>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- qqmath(~data, make.groups(x1, x2), groups = which,
+     distribution = qexp, aspect = "iso", type = c("p",
+         "g"))
&#62; print(pl)</pre>
</td>
</tr>
</table>
<table style="margin:.2em 0;">
<tr valign="top">
<td style="padding:.5em;">
<p><b><u>Note</u></b></p>
</td>
<td style="border-left:3px solid #e8e8e8;padding:.5em;"><tt>make.groups()</tt> function in <tt>lattice</tt> package &#8220;combines two or more vectors, possibly of different lengths, producing a data frame with a second column indicating which of these vectors that row came from&#8221;. Another alternative would be to use <tt>combine()</tt> function contained in <tt>gtools</tt> package.</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(make.groups(x1, x2)) + geom_point(aes(sample = data,
+     colour = which), stat = "qq", distribution = qexp) +
+     coord_equal()
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_05_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_05_l_small1.png" style="border-width:0;" alt="chapter10-10_05_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_05_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_05_r_small1.png" style="border-width:0;" alt="chapter10-10_05_r_small.png"> </a></p>
<h3><a name="_figure_10_6"></a>Figure 10.6</h3>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; beavers &#60;- make.groups(beaver1, beaver2)
&#62; beavers$hour &#60;- with(beavers, time%/%100 + 24 * (day -
+     307) + (time%%100)/60)</pre>
</td>
</tr>
</table>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- xyplot(temp ~ hour &#124; which, data = beavers, groups = activ,
+     auto.key = list(text = c("inactive", "active"), columns = 2),
+     xlab = "Time (hours)", ylab = "Body Temperature (C)",
+     scales = list(x = list(relation = "sliced")))
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(beavers, aes(hour, temp, colour = factor(activ))) +
+     geom_point() + facet_grid(~which, scales = "free_x") +
+     xlab("Time (hours)") + ylab("Body Temperature (C)")
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_06_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_06_l_small1.png" style="border-width:0;" alt="chapter10-10_06_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_06_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_06_r_small1.png" style="border-width:0;" alt="chapter10-10_06_r_small.png"> </a></p>
<h3><a name="_figure_10_7"></a>Figure 10.7</h3>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; data(USAge.df, package = "latticeExtra")</pre>
</td>
</tr>
</table>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- xyplot(Population ~ Age &#124; factor(Year), USAge.df,
+     groups = Sex, type = c("l", "g"), auto.key = list(points = FALSE,
+         lines = TRUE, columns = 2), aspect = "xy", ylab = "Population (millions)",
+     subset = Year %in% seq(1905, 1975, by = 10))
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(USAge.df, aes(Age, Population, colour = Sex)) +
+     geom_line(subset = .(Year %in% seq(1905, 1975, by = 10))) +
+     facet_wrap(~Year, ncol = 4) + ylab("Population (millions)")
&#62; print(pg)</pre>
</td>
</tr>
</table>
<table style="margin:.2em 0;">
<tr valign="top">
<td style="padding:.5em;">
<p><b><u>Note</u></b></p>
</td>
<td style="border-left:3px solid #e8e8e8;padding:.5em;"><tt>ggplot2</tt> doesn&#8217;t have the equivalent of <tt>aspect="xy"</tt> in <tt>lattice</tt>, which &#8220;<em>tries</em> to compute the aspect based on the 45 degree banking rule&#8221;.</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_07_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_07_l_small1.png" style="border-width:0;" alt="chapter10-10_07_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_07_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_07_r_small1.png" style="border-width:0;" alt="chapter10-10_07_r_small.png"> </a></p>
<h3><a name="_figure_10_8"></a>Figure 10.8</h3>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- xyplot(Population ~ Year &#124; factor(Age), USAge.df,
+     groups = Sex, type = "l", strip = FALSE, strip.left = TRUE,
+     layout = c(1, 3), ylab = "Population (millions)",
+     auto.key = list(lines = TRUE, points = FALSE, columns = 2),
+     subset = Age %in% c(0, 10, 20))
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(USAge.df, aes(Year, Population, colour = Sex)) +
+     geom_line(subset = .(Age %in% c(0, 10, 20))) + facet_grid(Age ~
+     .) + ylab("Population (millions)")
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_08_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_08_l_small1.png" style="border-width:0;" alt="chapter10-10_08_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_08_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_08_r_small1.png" style="border-width:0;" alt="chapter10-10_08_r_small.png"> </a></p>
<h3><a name="_figure_10_9"></a>Figure 10.9</h3>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- xyplot(Population ~ Year &#124; factor(Year - Age),
+     USAge.df, groups = Sex, subset = (Year - Age) %in%
+         1894:1905, type = c("g", "l"), ylab = "Population (millions)",
+     auto.key = list(lines = TRUE, points = FALSE, columns = 2))
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; USAge.df$YearAge &#60;- with(USAge.df, Year - Age)</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(USAge.df, aes(Year, Population, colour = Sex)) +
+     geom_line(subset = .((YearAge) %in% 1894:1905)) +
+     facet_wrap(~YearAge) + ylab("Population (millions)")
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_09_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_09_l_small1.png" style="border-width:0;" alt="chapter10-10_09_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_09_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_09_r_small1.png" style="border-width:0;" alt="chapter10-10_09_r_small.png"> </a></p>
<h3><a name="_figure_10_10"></a>Figure 10.10</h3>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- xyplot(stations ~ mag, quakes, jitter.x = TRUE,
+     type = c("p", "smooth"), xlab = "Magnitude (Richter)",
+     ylab = "Number of stations reporting")
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(quakes, aes(mag, stations)) + geom_jitter(position = position_jitter(width = 0.01),
+     shape = 1) + geom_smooth(method = "loess", se = F) +
+     xlab("Magnitude (Richter)") + ylab("Number of stations reporting")
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_10_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_10_l_small1.png" style="border-width:0;" alt="chapter10-10_10_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_10_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_10_r_small1.png" style="border-width:0;" alt="chapter10-10_10_r_small.png"> </a></p>
<h3><a name="_figure_10_11"></a>Figure 10.11</h3>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; quakes$Mag &#60;- equal.count(quakes$mag, number = 10, overlap = 0.2)</pre>
</td>
</tr>
</table>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; ps.mag &#60;- plot(quakes$Mag, ylab = "Level", xlab = "Magnitude (Richter)")
&#62; bwp.quakes &#60;- bwplot(stations ~ Mag, quakes, xlab = "Magnitude",
+     ylab = "Number of stations reporting")
&#62; plot(bwp.quakes, position = c(0, 0, 1, 0.65))
&#62; plot(ps.mag, position = c(0, 0.65, 1, 1), newpage = FALSE)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; Layout &#60;- grid.layout(nrow = 2, ncol = 1, heights = unit(c(1,
+     2), c("null", "null")))
&#62; grid.show.layout(Layout)
&#62; vplayout &#60;- function(...) {
+     grid.newpage()
+     pushViewport(viewport(layout = Layout))
+ }
&#62; subplot &#60;- function(x, y) viewport(layout.pos.row = x,
+     layout.pos.col = y)
&#62; pr &#60;- function() {
+     vplayout()
+     print(p1, vp = subplot(1, 1))
+     print(p2, vp = subplot(2, 1))
+ }</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; fn &#60;- function(data = quakes$mag, number = 4, ...) {
+     intrv &#60;&#60;- as.data.frame(co.intervals(data, number,
+         ...))
+     mag &#60;- sort(unique(data))
+     intervals &#60;- ldply(mag, function(x) {
+         t(as.numeric(x &#60; intrv$V2 &#38; x &#62; intrv$V1))
+     })
+     tmp &#60;- melt(cbind(mag, intervals), id.var = 1)
+     tmp[tmp$value &#62; 0, 1:2]
+ }
&#62; quakes.ordered &#60;- merge(quakes, fn(number = 10, overlap = 0.2))
&#62; intrv &#60;- with(intrv, paste(V1, V2, sep = "-"))
&#62; quakes.ordered &#60;- rename(quakes.ordered, c(variable = "magnitude"))
&#62; quakes.ordered$magnitude &#60;- factor(quakes.ordered$magnitude,
+     labels = intrv)</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; p1 &#60;- ggplot(fn(number = 10, overlap = 0.2), aes(variable,
+     mag)) + stat_summary(aes(xmin = as.numeric(variable) -
+     0.4, xmax = as.numeric(variable) + 0.4), fun.ymin = min,
+     fun.ymax = max, geom = "rect") + coord_flip()
&#62; p2 &#60;- ggplot(quakes.ordered, aes(as.numeric(magnitude),
+     stations, group = magnitude)) + geom_boxplot() +
+     xlab("Magnitude") + ylab("Number of stations reporting")
&#62; pr()</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_11_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_11_l_small1.png" style="border-width:0;" alt="chapter10-10_11_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_11_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_11_r_small1.png" style="border-width:0;" alt="chapter10-10_11_r_small.png"> </a></p>
<h3><a name="_figure_10_12"></a>Figure 10.12</h3>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- bwplot(sqrt(stations) ~ Mag, quakes, scales = list(x = list(limits = as.character(levels(quakes$Mag)),
+     rot = 60)), xlab = "Magnitude (Richter)", ylab = expression(sqrt("Number of stations")))
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(quakes.ordered, aes(magnitude, sqrt(stations),
+     group = magnitude)) + geom_boxplot() + xlab("Magnitude (Richter)") +
+     ylab(expression(sqrt("Number of stations"))) + opts(axis.text.x = theme_text(angle = 45,
+     hjust = 1, colour = "grey50"))
&#62; print(pg)</pre>
</td>
</tr>
</table>
<table style="margin:.2em 0;">
<tr valign="top">
<td style="padding:.5em;">
<p><b><u>Note</u></b></p>
</td>
<td style="border-left:3px solid #e8e8e8;padding:.5em;"><tt>ggplot2</tt> doesn&#8217;t have the equivalent of <tt>aspect="xy"</tt> in <tt>lattice</tt>, which &#8220;<em>tries</em> to compute the aspect based on the 45 degree banking rule&#8221;.</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_12_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_12_l_small1.png" style="border-width:0;" alt="chapter10-10_12_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_12_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_12_r_small1.png" style="border-width:0;" alt="chapter10-10_12_r_small.png"> </a></p>
<h3><a name="_figure_10_13"></a>Figure 10.13</h3>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- qqmath(~sqrt(stations) &#124; Mag, quakes, type = c("p",
+     "g"), pch = ".", cex = 3, prepanel = prepanel.qqmathline,
+     aspect = "xy", strip = strip.custom(strip.levels = TRUE,
+         strip.names = FALSE), xlab = "Standard normal quantiles",
+     ylab = expression(sqrt("Number of stations")))
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(quakes.ordered, aes(sample = sqrt(stations))) +
+     geom_point(stat = "qq") + facet_wrap(~magnitude,
+     nrow = 2) + scale_x_continuous("Standard normal quantiles") +
+     scale_y_continuous(expression(sqrt("Number of stations")))
&#62; print(pg)</pre>
</td>
</tr>
</table>
<table style="margin:.2em 0;">
<tr valign="top">
<td style="padding:.5em;">
<p><b><u>Note</u></b></p>
</td>
<td style="border-left:3px solid #e8e8e8;padding:.5em;"><tt>ggplot2</tt> doesn&#8217;t have the equivalent of <tt>aspect="xy"</tt> in <tt>lattice</tt>, which &#8220;<em>tries</em> to compute the aspect based on the 45 degree banking rule&#8221;.</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_13_l1.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_13_l_small1.png" style="border-width:0;" alt="chapter10-10_13_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_13_r1.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_13_r_small1.png" style="border-width:0;" alt="chapter10-10_13_r_small.png"> </a></p>
<h3><a name="_figure_10_14"></a>Figure 10.14</h3>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- xyplot(sqrt(stations) ~ mag, quakes, cex = 0.6,
+     panel = panel.bwplot, horizontal = FALSE, box.ratio = 0.05,
+     xlab = "Magnitude (Richter)", ylab = expression(sqrt("Number of stations")))
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(quakes.ordered, aes(factor(mag), sqrt(stations))) +
+     geom_boxplot() + xlab("Magnitude (Richter)") + ylab(expression(sqrt("Number of stations")))
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_14_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_14_l_small1.png" style="border-width:0;" alt="chapter10-10_14_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_14_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_14_r_small1.png" style="border-width:0;" alt="chapter10-10_14_r_small.png"> </a></p>
<h3><a name="_figure_10_15"></a>Figure 10.15</h3>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; state.density &#60;- data.frame(name = state.name, area = state.x77[,
+     "Area"], population = state.x77[, "Population"],
+     region = state.region)
&#62; state.density$density &#60;- with(state.density, population/area)</pre>
</td>
</tr>
</table>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- dotplot(reorder(name, density) ~ density, state.density,
+     xlab = "Population Density (thousands per square mile)")
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(state.density, aes(density, reorder(name,
+     density))) + geom_point() + xlab("Population Density (thousands per square mile)")
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_15_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_15_l_small1.png" style="border-width:0;" alt="chapter10-10_15_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_15_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_15_r_small1.png" style="border-width:0;" alt="chapter10-10_15_r_small.png"> </a></p>
<h3><a name="_figure_10_16"></a>Figure 10.16</h3>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; state.density$Density &#60;- shingle(state.density$density,
+     intervals = rbind(c(0, 0.2), c(0.2, 1)))</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- dotplot(reorder(name, density) ~ density &#124; Density,
+     state.density, strip = FALSE, layout = c(2, 1), levels.fos = 1:50,
+     scales = list(x = "free"), between = list(x = 0.5),
+     xlab = "Population Density (thousands per square mile)",
+     par.settings = list(layout.widths = list(panel = c(2,
+         1))))
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; state.density$pos &#60;- state.density$density &#62; 0.2</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(state.density, aes(density, reorder(name,
+     density))) + geom_point() + facet_grid(~pos, scales = "free_x") +
+     xlab("Population Density (thousands per square mile)") +
+     opts(strip.background = theme_blank(), strip.text.x = theme_blank())
&#62; print(pg)</pre>
</td>
</tr>
</table>
<table style="margin:.2em 0;">
<tr valign="top">
<td style="padding:.5em;">
<p><b><u>Note</u></b></p>
</td>
<td style="border-left:3px solid #e8e8e8;padding:.5em;">It is not possible to change the facet width in <tt>ggplot2</tt>.</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_16_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_16_l_small1.png" style="border-width:0;" alt="chapter10-10_16_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_16_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_16_r_small1.png" style="border-width:0;" alt="chapter10-10_16_r_small.png"> </a></p>
<h3><a name="_figure_10_17"></a>Figure 10.17</h3>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; cutAndStack &#60;- function(x, number = 6, overlap = 0.1,
+     type = "l", xlab = "Time", ylab = deparse(substitute(x)),
+     ...) {
+     time &#60;- if (is.ts(x))
+         time(x)
+     else seq_along(x)
+     Time &#60;- equal.count(as.numeric(time), number = number,
+         overlap = overlap)
+     xyplot(as.numeric(x) ~ time &#124; Time, type = type,
+         xlab = xlab, ylab = ylab, default.scales = list(x = list(relation = "free"),
+             y = list(relation = "free")), ...)
+ }</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- cutAndStack(EuStockMarkets[, "DAX"], aspect = "xy",
+     scales = list(x = list(draw = FALSE), y = list(rot = 0)))
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; library(zoo)</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; cutAndStack_g &#60;- function(data, number = 4, overlap = 0.1) {
+     ylab = deparse(substitute(data))
+     data &#60;- as.data.frame(data)
+     data$id &#60;- if (is.ts(data$x))
+         time(data$x)
+     else seq_along(data$x)
+     intrv &#60;&#60;- as.data.frame(co.intervals(data$id, number,
+         overlap))
+     x &#60;- sort(unique(data$id))
+     intervals &#60;- ldply(x, function(x) {
+         t(as.numeric(x &#60; intrv$V2 &#38; x &#62; intrv$V1))
+     })
+     tmp &#60;- melt(cbind(x, intervals), id.var = 1)
+     tmp &#60;- tmp[tmp$value &#62; 0, 1:2]
+     tmp &#60;- rename(tmp, c(x = "id"))
+     stock &#60;- merge(data, tmp)
+     stock$variable &#60;- factor(stock$variable, labels = with(intrv,
+         paste(as.yearmon(V1), as.yearmon(V2), sep = " - ")))
+     p &#60;- ggplot(stock, aes(id, x)) + geom_line() + facet_wrap(~variable,
+         scales = "free", ncol = 1, as.table = FALSE) +
+         scale_x_continuous("", breaks = NA) + ylab(ylab)
+     print(p)
+ }</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; cutAndStack_g(data = EuStockMarkets[, "DAX"], number = 6,
+     overlap = 0.1)</pre>
</td>
</tr>
</table>
<table style="margin:.2em 0;">
<tr valign="top">
<td style="padding:.5em;">
<p><b><u>Note</u></b></p>
</td>
<td style="border-left:3px solid #e8e8e8;padding:.5em;"><tt>ggplot2</tt> doesn&#8217;t have the equivalent of <em>aspect=&#8221;xy&#8221;</em> in lattice, which &#8220;<em>tries</em> to compute the aspect based on the 45 degree banking rule&#8221;.</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_17_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_17_l_small1.png" style="border-width:0;" alt="chapter10-10_17_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_17_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_17_r_small1.png" style="border-width:0;" alt="chapter10-10_17_r_small.png"> </a></p>
<h3><a name="_figure_10_18"></a>Figure 10.18</h3>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; bdp1 &#60;- dotplot(as.character(variety) ~ yield &#124; as.character(site),
+     barley, groups = year, layout = c(1, 6), auto.key = list(space = "top",
+         columns = 2), aspect = "fill")
&#62; bdp2 &#60;- dotplot(variety ~ yield &#124; site, barley, groups = year,
+     layout = c(1, 6), auto.key = list(space = "top",
+         columns = 2), aspect = "fill")
&#62; plot(bdp1, split = c(1, 1, 2, 1))
&#62; plot(bdp2, split = c(2, 1, 2, 1), newpage = FALSE)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; Layout &#60;- grid.layout(ncol = 3, widths = unit(c(2, 2,
+     0.75), c("null", "null", "null")))
&#62; vplayout &#60;- function(...) {
+     grid.newpage()
+     pushViewport(viewport(layout = Layout))
+ }
&#62; subplot &#60;- function(x, y) viewport(layout.pos.row = x,
+     layout.pos.col = y)
&#62; pr &#60;- function() {
+     vplayout()
+     print(p_left, vp = subplot(1, 1))
+     print(p_right, vp = subplot(1, 2))
+     print(legend, vp = subplot(1, 3))
+ }</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; p &#60;- ggplot(barley, aes(yield, variety, colour = year)) +
+     geom_point() + facet_wrap(~site, ncol = 1) + ylab("")
&#62; legend &#60;- p + opts(keep = "legend_box")
&#62; p_right &#60;- p + opts(legend.position = "none")
&#62; barley$site &#60;- factor(barley$site, levels = sort(levels(barley$site)))
&#62; barley$variety &#60;- factor(barley$variety, levels = sort(levels(barley$variety)))
&#62; p_left &#60;- p_right %+% barley
&#62; pr()</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_18_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_18_l_small1.png" style="border-width:0;" alt="chapter10-10_18_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_18_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_18_r_small1.png" style="border-width:0;" alt="chapter10-10_18_r_small.png"> </a></p>
<h3><a name="_figure_10_19"></a>Figure 10.19</h3>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; state.density &#60;- data.frame(name = state.name, area = state.x77[,
+     "Area"], population = state.x77[, "Population"],
+     region = state.region)
&#62; state.density$density &#60;- with(state.density, population/area)</pre>
</td>
</tr>
</table>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- dotplot(reorder(name, density) ~ 1000 * density,
+     state.density, scales = list(x = list(log = 10)),
+     xlab = "Density (per square mile)")
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(state.density, aes(density * 1000, reorder(name,
+     density))) + geom_point() + scale_x_log10() + xlab("Density (per square mile)") +
+     ylab("")
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_19_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_19_l_small1.png" style="border-width:0;" alt="chapter10-10_19_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_19_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_19_r_small1.png" style="border-width:0;" alt="chapter10-10_19_r_small.png"> </a></p>
<h3><a name="_figure_10_20"></a>Figure 10.20</h3>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; state.density$region &#60;- with(state.density, reorder(region,
+     density, median))
&#62; state.density$name &#60;- with(state.density, reorder(reorder(name,
+     density), as.numeric(region)))</pre>
</td>
</tr>
</table>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- dotplot(name ~ 1000 * density &#124; region, state.density,
+     strip = FALSE, strip.left = TRUE, layout = c(1, 4),
+     scales = list(x = list(log = 10), y = list(relation = "free")),
+     xlab = "Density (per square mile)")
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(state.density, aes(1000 * density, name)) +
+     geom_point() + facet_grid(region ~ ., scales = "free_y") +
+     scale_x_log10() + xlab("Density (per square mile)") +
+     ylab("")
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_20_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_20_l_small1.png" style="border-width:0;" alt="chapter10-10_20_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_20_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_20_r_small1.png" style="border-width:0;" alt="chapter10-10_20_r_small.png"> </a></p>
<h3><a name="_figure_10_21"></a>Figure 10.21</h3>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; library("latticeExtra")</pre>
</td>
</tr>
</table>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; print(pl)
&#62; print(resizePanels())</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- pg + facet_grid(region~., scales = "free_y", space = "free", as.table = FALSE)
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_21_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_21_l_small1.png" style="border-width:0;" alt="chapter10-10_21_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_21_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_21_r_small.png" style="border-width:0;" alt="chapter10-10_21_r_small.png"> </a></p>
<h3><a name="_figure_10_22"></a>Figure 10.22</h3>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; data(USCancerRates, package = "latticeExtra")</pre>
</td>
</tr>
</table>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- xyplot(rate.male ~ rate.female &#124; state, USCancerRates,
+     aspect = "iso", pch = ".", cex = 2, index.cond = function(x,
+         y) {
+         median(y - x, na.rm = TRUE)
+     }, scales = list(log = 2, at = c(75, 150, 300, 600)),
+     panel = function(...) {
+         panel.grid(h = -1, v = -1)
+         panel.abline(0, 1)
+         panel.xyplot(...)
+     })
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; med &#60;- ddply(USCancerRates, .(state), summarise, med = median(rate.female -
+     rate.male, na.rm = TRUE))
&#62; med$state &#60;- with(med, reorder(state, med))
&#62; USCancerRates$state &#60;- factor(USCancerRates$state, levels = levels(med$state))</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(USCancerRates, aes(rate.female, rate.male)) +
+     geom_point(size = 1) + geom_abline(intercept = 0,
+     slope = 1) + scale_x_log2(breaks = c(75, 150, 300,
+     600), labels = c(75, 150, 300, 600)) + scale_y_log2(breaks = c(75,
+     150, 300, 600), labels = c(75, 150, 300, 600)) +
+     facet_wrap(~state, ncol = 7)
&#62; print(pg)</pre>
</td>
</tr>
</table>
<table style="margin:.2em 0;">
<tr valign="top">
<td style="padding:.5em;">
<p><b><u>Note</u></b></p>
</td>
<td style="border-left:3px solid #e8e8e8;padding:.5em;">For some strange reason the order of facets is different compared to <tt>lattice</tt> plot, although the formula to set the levels is the same!</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_22_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_22_l_small1.png" style="border-width:0;" alt="chapter10-10_22_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_22_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_22_r_small1.png" style="border-width:0;" alt="chapter10-10_22_r_small.png"> </a></p>
<h3><a name="_figure_10_23"></a>Figure 10.23</h3>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; data(Chem97, package = "mlmRev")</pre>
</td>
</tr>
</table>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; strip.style4 &#60;- function(..., style) {
+     strip.default(..., style = 4)
+ }</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- qqmath(~gcsescore &#124; factor(score), Chem97, groups = gender,
+     type = c("l", "g"), aspect = "xy", auto.key = list(points = FALSE,
+         lines = TRUE, columns = 2), f.value = ppoints(100),
+     strip = strip.style4, xlab = "Standard normal quantiles",
+     ylab = "Average GCSE score")
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(Chem97, aes(sample = gcsescore, colour = gender)) +
+     geom_point(stat = "qq", quantiles = ppoints(100)) +
+     facet_wrap(~score) + scale_x_continuous("Standard Normal Quantiles") +
+     scale_y_continuous("Average GCSE Score") + theme_bw()
&#62; print(pg)</pre>
</td>
</tr>
</table>
<table style="margin:.2em 0;">
<tr valign="top">
<td style="padding:.5em;">
<p><b><u>Note</u></b></p>
</td>
<td style="border-left:3px solid #e8e8e8;padding:.5em;"><tt>ggplot2</tt> doesn&#8217;t have the equivalent of <tt>aspect="xy"</tt> in <tt>lattice</tt>, which &#8220;<em>tries</em> to compute the aspect based on the 45 degree banking rule&#8221;.</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_23_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_23_l_small1.png" style="border-width:0;" alt="chapter10-10_23_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_23_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_23_r_small1.png" style="border-width:0;" alt="chapter10-10_23_r_small.png"> </a></p>
<h3><a name="_figure_10_24"></a>Figure 10.24</h3>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; strip.combined &#60;- function(which.given, which.panel,
+     factor.levels, ...) {
+     if (which.given == 1) {
+         panel.rect(0, 0, 1, 1, col = "grey90", border = 1)
+         panel.text(x = 0, y = 0.5, pos = 4, lab = factor.levels[which.panel[which.given]])
+     }
+     if (which.given == 2) {
+         panel.text(x = 1, y = 0.5, pos = 2, lab = factor.levels[which.panel[which.given]])
+     }
+ }</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- qqmath(~gcsescore &#124; factor(score) + gender, Chem97,
+     f.value = ppoints(100), type = c("l", "g"), aspect = "xy",
+     strip = strip.combined, par.strip.text = list(lines = 0.5),
+     xlab = "Standard normal quantiles", ylab = "Average GCSE score")
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; Chem97 &#60;- transform(Chem97, sc_gen = paste(score, gender))</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; library(gtools)
&#62; Chem97$sc_gen &#60;- factor(Chem97$sc_gen, levels = mixedsort(unique(Chem97$sc_gen)))</pre>
</td>
</tr>
</table>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(Chem97, aes(sample = gcsescore)) + geom_point(stat = "qq",
+     quantiles = ppoints(100)) + facet_wrap(~sc_gen, nrow = 2) +
+     scale_x_continuous("Standard normal quantiles") +
+     scale_y_continuous("Average GCSE score")
&#62; print(pg)</pre>
</td>
</tr>
</table>
<table style="margin:.2em 0;">
<tr valign="top">
<td style="padding:.5em;">
<p><b><u>Note</u></b></p>
</td>
<td style="border-left:3px solid #e8e8e8;padding:.5em;"><tt>ggplot2</tt> doesn&#8217;t have the equivalent of <tt>aspect="xy"</tt> in <tt>lattice</tt>, which &#8220;<em>tries</em> to compute the aspect based on the 45 degree banking rule&#8221;.</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_24_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_24_l_small1.png" style="border-width:0;" alt="chapter10-10_24_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_24_r.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_24_r_small1.png" style="border-width:0;" alt="chapter10-10_24_r_small.png"> </a></p>
<h3><a name="_figure_10_25"></a>Figure 10.25</h3>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; morris &#60;- barley$site == "Morris"
&#62; barley$year[morris] &#60;- ifelse(barley$year[morris] ==
+     "1931", "1932", "1931")</pre>
</td>
</tr>
</table>
<p><strong><tt>lattice</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pl &#60;- stripplot(sqrt(abs(residuals(lm(yield ~ variety +
+     year + site)))) ~ site, data = barley, groups = year,
+     jitter.data = TRUE, auto.key = list(points = TRUE,
+         lines = TRUE, columns = 2), type = c("p", "a"),
+     fun = median, ylab = expression(abs("Residual Barley Yield")^{
+         1/2
+     }))
&#62; print(pl)</pre>
</td>
</tr>
</table>
<p><strong><tt>ggplot2</tt></strong></p>
<table border="0" bgcolor="#e8e8e8" width="100%" style="margin:.2em 0;">
<tr>
<td style="padding:.5em;">
<pre style="margin:0;padding:0;">&#62; pg &#60;- ggplot(barley, aes(site, sqrt(abs(residuals(lm(yield ~
+     variety + year + site)))), colour = year)) + geom_jitter(position = position_jitter(w = 0.1)) +
+     geom_line(stat = "summary", fun.y = median, aes(group = year)) +
+     ylab(expression(abs("Residual Barley Yield")^{
+         1/2
+     }))
&#62; print(pg)</pre>
</td>
</tr>
</table>
<p><a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_25_l.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_25_l_small1.png" style="border-width:0;" alt="chapter10-10_25_l_small.png"> </a> <a href="http://learnr.files.wordpress.com/2009/08/chapter10-10_25_r1.png"> <img src="http://learnr.files.wordpress.com/2009/08/chapter10-10_25_r_small1.png" style="border-width:0;" alt="chapter10-10_25_r_small.png"> </a></p>
</div>]]></content:encoded>
</item>

</channel>
</rss>
