<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.taichimd.us/index.php?action=history&amp;feed=atom&amp;title=File%3AGeom_bar_reorder.png</id>
	<title>File:Geom bar reorder.png - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.taichimd.us/index.php?action=history&amp;feed=atom&amp;title=File%3AGeom_bar_reorder.png"/>
	<link rel="alternate" type="text/html" href="https://wiki.taichimd.us/index.php?title=File:Geom_bar_reorder.png&amp;action=history"/>
	<updated>2026-04-05T15:52:50Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://wiki.taichimd.us/index.php?title=File:Geom_bar_reorder.png&amp;diff=39993&amp;oldid=prev</id>
		<title>Brb: &lt;syntaxhighlight lang=&#039;r&#039;&gt;
library(ggplot2)
library(forcats)

data &lt;- data.frame(
  category = c(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;),
  value = c(3, 5, 2, 8)
)

data$category &lt;- fct_reorder(data$category, data$value)

levels(data$category)
# [1] &quot;C&quot; &quot;A&quot; &quot;B&quot; &quot;D&quot;

ggplot(data, aes(x = category, y = value, fill = category)) +
  geom_bar(stat = &quot;identity&quot;) +
  coord_flip() +
  labs(x = &quot;Category&quot;, y = &quot;Value&quot;) +
  theme_minimal()
&lt;/syntaxhighlight&gt;</title>
		<link rel="alternate" type="text/html" href="https://wiki.taichimd.us/index.php?title=File:Geom_bar_reorder.png&amp;diff=39993&amp;oldid=prev"/>
		<updated>2024-08-13T19:54:50Z</updated>

		<summary type="html">&lt;p&gt;&amp;lt;syntaxhighlight lang=&amp;#039;r&amp;#039;&amp;gt; library(ggplot2) library(forcats)  data &amp;lt;- data.frame(   category = c(&amp;quot;A&amp;quot;, &amp;quot;B&amp;quot;, &amp;quot;C&amp;quot;, &amp;quot;D&amp;quot;),   value = c(3, 5, 2, 8) )  data$category &amp;lt;- fct_reorder(data$category, data$value)  levels(data$category) # [1] &amp;quot;C&amp;quot; &amp;quot;A&amp;quot; &amp;quot;B&amp;quot; &amp;quot;D&amp;quot;  ggplot(data, aes(x = category, y = value, fill = category)) +   geom_bar(stat = &amp;quot;identity&amp;quot;) +   coord_flip() +   labs(x = &amp;quot;Category&amp;quot;, y = &amp;quot;Value&amp;quot;) +   theme_minimal() &amp;lt;/syntaxhighlight&amp;gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Summary ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;#039;r&amp;#039;&amp;gt;&lt;br /&gt;
library(ggplot2)&lt;br /&gt;
library(forcats)&lt;br /&gt;
&lt;br /&gt;
data &amp;lt;- data.frame(&lt;br /&gt;
  category = c(&amp;quot;A&amp;quot;, &amp;quot;B&amp;quot;, &amp;quot;C&amp;quot;, &amp;quot;D&amp;quot;),&lt;br /&gt;
  value = c(3, 5, 2, 8)&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
data$category &amp;lt;- fct_reorder(data$category, data$value)&lt;br /&gt;
&lt;br /&gt;
levels(data$category)&lt;br /&gt;
# [1] &amp;quot;C&amp;quot; &amp;quot;A&amp;quot; &amp;quot;B&amp;quot; &amp;quot;D&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ggplot(data, aes(x = category, y = value, fill = category)) +&lt;br /&gt;
  geom_bar(stat = &amp;quot;identity&amp;quot;) +&lt;br /&gt;
  coord_flip() +&lt;br /&gt;
  labs(x = &amp;quot;Category&amp;quot;, y = &amp;quot;Value&amp;quot;) +&lt;br /&gt;
  theme_minimal()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Brb</name></author>
	</entry>
</feed>