<?xml version="1.0" encoding="UTF-8"?>
<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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>scienceoss.com &#187; factors</title>
	<atom:link href="http://scienceoss.com/tags/factors/feed/" rel="self" type="application/rss+xml" />
	<link>http://scienceoss.com</link>
	<description>useful tidbits for using open source software in science</description>
	<lastBuildDate>Wed, 26 May 2010 03:34:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Reorder factors for ggplot</title>
		<link>http://scienceoss.com/reorder-factors-for-ggplot/</link>
		<comments>http://scienceoss.com/reorder-factors-for-ggplot/#comments</comments>
		<pubDate>Sun, 23 Mar 2008 21:35:45 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[ggplot2]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[facet grid]]></category>
		<category><![CDATA[factors]]></category>
		<category><![CDATA[ggplot]]></category>
		<category><![CDATA[reorder]]></category>

		<guid isPermaLink="false">http://scienceoss.com/reorder-factors-for-ggplot/</guid>
		<description><![CDATA[A somewhat contrived example . . . first, illustrate the problem: library(ggplot2) ggplot(iris)+aes(x=Sepal.Width)+geom_histogram()+facet_grid(Species~.) How do we get these histograms to be better sorted? The following will reorder the factor variable, Species, by the mean of Sepal.Width: iris$Species = reorder(iris$Species, iris$Sepal.Width, mean) ggplot(iris)+aes(x=Sepal.Width)+geom_histogram()+facet_grid(Species~.) Now the histograms are sorted by the mean sepal width.]]></description>
			<content:encoded><![CDATA[<p>A somewhat contrived example . . . first, illustrate the problem:</p>
<pre class="prettyprint"><code class="code">library(ggplot2)
ggplot(iris)+aes(x=Sepal.Width)+geom_histogram()+facet_grid(Species~.)</code></pre>
<p><a href='http://scienceoss.com/wp-content/uploads/2008/03/hist-unsorted.png' title='Unsorted histogram'><img src='http://scienceoss.com/wp-content/uploads/2008/03/hist-unsorted.png' alt='Unsorted histogram' /></a><br />
How do we get these histograms to be better sorted?  The following will reorder the factor variable, <span class="c">Species</span>, by the mean of <span class="c">Sepal.Width</span>:</p>
<pre class="prettyprint"><code class="code">iris$Species = reorder(iris$Species, iris$Sepal.Width, mean)
ggplot(iris)+aes(x=Sepal.Width)+geom_histogram()+facet_grid(Species~.)</code></pre>
<p><a href='http://scienceoss.com/wp-content/uploads/2008/03/hist-sorted.png' title='Sorted histogram'><img src='http://scienceoss.com/wp-content/uploads/2008/03/hist-sorted.png' alt='Sorted histogram' /></a><br />
Now the histograms are sorted by the mean sepal width.</p>
]]></content:encoded>
			<wfw:commentRss>http://scienceoss.com/reorder-factors-for-ggplot/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

