<?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>R-statistics blog &#187; dietary research</title>
	<atom:link href="http://www.r-statistics.com/tag/dietary-research/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.r-statistics.com</link>
	<description>Writing about statistics with R, and open source stuff (software, data, community)</description>
	<lastBuildDate>Mon, 30 Jan 2012 07:45:09 +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>Nutritional supplements efficacy score &#8211; Graphing plots of current studies results (using R)</title>
		<link>http://www.r-statistics.com/2010/02/nutritional-supplements-efficacy-score-graphing-plots-of-current-studies-results-using-r/</link>
		<comments>http://www.r-statistics.com/2010/02/nutritional-supplements-efficacy-score-graphing-plots-of-current-studies-results-using-r/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 21:17:07 +0000</pubDate>
		<dc:creator>Tal Galili</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[statistics]]></category>
		<category><![CDATA[visualization]]></category>
		<category><![CDATA[allergy research supplements]]></category>
		<category><![CDATA[amino acids supplements]]></category>
		<category><![CDATA[balloon]]></category>
		<category><![CDATA[balloon plot]]></category>
		<category><![CDATA[balloon plot R]]></category>
		<category><![CDATA[barplot]]></category>
		<category><![CDATA[benefits supplements]]></category>
		<category><![CDATA[capsules supplements]]></category>
		<category><![CDATA[dietary research]]></category>
		<category><![CDATA[effects supplements]]></category>
		<category><![CDATA[fibromyalgia research]]></category>
		<category><![CDATA[glucosamine research]]></category>
		<category><![CDATA[glucosamine supplements]]></category>
		<category><![CDATA[google excel]]></category>
		<category><![CDATA[google spread sheet]]></category>
		<category><![CDATA[google spreadsheet]]></category>
		<category><![CDATA[green tea research]]></category>
		<category><![CDATA[hair loss research]]></category>
		<category><![CDATA[herbal research]]></category>
		<category><![CDATA[herbs research]]></category>
		<category><![CDATA[herbs supplements]]></category>
		<category><![CDATA[immune system supplements]]></category>
		<category><![CDATA[liquid research]]></category>
		<category><![CDATA[liquid supplements]]></category>
		<category><![CDATA[magnesium research]]></category>
		<category><![CDATA[mineral research]]></category>
		<category><![CDATA[minerals research]]></category>
		<category><![CDATA[natural health supplements]]></category>
		<category><![CDATA[natural research]]></category>
		<category><![CDATA[nutritional research]]></category>
		<category><![CDATA[plot]]></category>
		<category><![CDATA[pregnancy supplements]]></category>
		<category><![CDATA[R code]]></category>
		<category><![CDATA[side effects supplements]]></category>
		<category><![CDATA[sports nutrition supplements]]></category>
		<category><![CDATA[supplement research]]></category>
		<category><![CDATA[supplements body building]]></category>
		<category><![CDATA[supplements bodybuilding]]></category>
		<category><![CDATA[supplements dietary]]></category>
		<category><![CDATA[supplements foods]]></category>
		<category><![CDATA[supplements herbal]]></category>
		<category><![CDATA[supplements mineral]]></category>
		<category><![CDATA[supplements minerals]]></category>
		<category><![CDATA[supplements nutritional]]></category>
		<category><![CDATA[supplements products]]></category>
		<category><![CDATA[supplements protein]]></category>
		<category><![CDATA[supplements research]]></category>
		<category><![CDATA[take supplements]]></category>
		<category><![CDATA[taking supplements]]></category>
		<category><![CDATA[thyroid research]]></category>
		<category><![CDATA[vitamin b supplements]]></category>
		<category><![CDATA[vitamin c research]]></category>
		<category><![CDATA[vitamin c supplements]]></category>
		<category><![CDATA[vitamin d research]]></category>
		<category><![CDATA[vitamins discount]]></category>
		<category><![CDATA[vitamins minerals supplements]]></category>
		<category><![CDATA[vitamins research]]></category>
		<category><![CDATA[weight loss research]]></category>

		<guid isPermaLink="false">http://www.r-statistics.com/?p=171</guid>
		<description><![CDATA[In this post I showcase a nice bar-plot and a balloon-plot listing recommended Nutritional supplements , according to how much evidence exists for thier benefits, scroll down to see it(and click here for the data behind it) * * * * The gorgeous blog &#8220;Information Is Beautiful&#8221; recently publish an eye candy post showing a [...]]]></description>
			<content:encoded><![CDATA[<div class="socialize-in-content" style="float:right;"><div class="socialize-in-button socialize-in-button-right"><iframe src="http://www.facebook.com/plugins/like.php?href=http://www.r-statistics.com/2010/02/nutritional-supplements-efficacy-score-graphing-plots-of-current-studies-results-using-r/&amp;layout=box_count&amp;show_faces=false&amp;width=50&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px !important; height:65px;" allowTransparency="true"></iframe></div><div class="socialize-in-button socialize-in-button-right"><g:plusone size="tall" href="http://www.r-statistics.com/2010/02/nutritional-supplements-efficacy-score-graphing-plots-of-current-studies-results-using-r/"></g:plusone></div></div><p>In this post I showcase a nice <strong>bar-plot and a balloon-plot listing recommended Nutritional supplements</strong> , according to how much evidence exists for thier benefits, scroll down to see it(and <a href="http://spreadsheets.google.com/ccc?key=0Aqe2P9sYhZ2ndFRKaU1FaWVvOEJiV2NwZ0JHck12X1E&amp;hl=en_GB">click here</a> for the data behind it)<br />
*  *  *  *<br />
The gorgeous blog <a href="http://www.informationisbeautiful.net/">&#8220;Information Is Beautiful&#8221;</a> recently publish an <a href="http://www.informationisbeautiful.net/play/snake-oil-supplements/">eye candy post</a> showing a “balloon race” image (see a static version of the image <a href="http://www.informationisbeautiful.net/visualizations/snake-oil-supplements/">here</a>) illustrating how much evidence exists for the benefits of various Nutritional supplements (such as: green tea, vitamins, herbs, pills and so on) . The higher the bubble in the Y axis <del datetime="2010-03-06T11:34:54+00:00">score (e.g: the bubble size)</del> for the supplement the greater the evidence there is for its effectiveness (But only for the conditions listed along side the supplement).</p>
<p>There are two reasons this should be of interest to us:</p>
<ol>
<li>This shows a fun plot, that R currently doesn&#8217;t know how to do (at least I wasn&#8217;t able to find an implementation for it). So if anyone thinks of an easy way for making one &#8211; please let me know.</li>
<li>The data for the graph is openly (and freely) provided to all of us on <a href="http://spreadsheets.google.com/ccc?key=0Aqe2P9sYhZ2ndFRKaU1FaWVvOEJiV2NwZ0JHck12X1E&amp;hl=en_GB">this Google Doc</a>.</li>
</ol>
<p>The advantage of having the data on a google doc means that we can see when the data will be updated. But more then that, it means we can easily extract the data into R and have our way with it  (Thanks to <a href="http://blog.revolution-computing.com/2009/09/how-to-use-a-google-spreadsheet-as-data-in-r.html">David Smith&#8217;s post </a>on the subject)</p>
<p>For example, I was wondering what are ALL of the top recommended Nutritional supplements, an answer that is not trivial to get from the plot that was in the <a href="http://www.informationisbeautiful.net/play/snake-oil-supplements/">original post</a>.</p>
<p>In this post I will supply two plots that present the data: A barplot (that in retrospect didn&#8217;t prove to be good enough) and a balloon-plot for a table (that seems to me to be much better).</p>
<p><strong>Barplot</strong><br />
(You can <strong>click the image to enlarge</strong> it)<br />
<a href="http://www.r-statistics.com/wp-content/uploads/2010/02/Nutritional-supplements-efficacy.png"><img class="alignnone size-full wp-image-172" title="Nutritional supplements efficacy" src="http://www.r-statistics.com/wp-content/uploads/2010/02/Nutritional-supplements-efficacy.png" alt="" width="550" /></a></p>
<p>The R code to produce the barplot of Nutritional supplements efficacy score (by evidence for its effectiveness on the listed condition).</p>

<div class="wp_codebox"><table><tr id="p1713"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code" id="p171code3"><pre class="rsplus" style="font-family:monospace;">&nbsp;
<span style="color: #228B22;"># loading the data</span>
supplements.<span style="">data</span>.0 <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">read.<span style="">csv</span></span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;http://spreadsheets.google.com/pub?key=0Aqe2P9sYhZ2ndFRKaU1FaWVvOEJiV2NwZ0JHck12X1E&amp;output=csv&quot;</span><span style="color: #080;">&#41;</span>
supplements.<span style="">data</span> <span style="color: #080;">&lt;-</span> supplements.<span style="">data</span>.0<span style="color: #080;">&#91;</span>supplements.<span style="">data</span>.0<span style="color: #080;">&#91;</span>,<span style="color: #ff0000;">2</span><span style="color: #080;">&#93;</span> <span style="color: #080;">&gt;</span><span style="color: #ff0000;">2</span>,<span style="color: #080;">&#93;</span> <span style="color: #228B22;"># let's only look at &quot;good&quot; supplements</span>
supplements.<span style="">data</span> <span style="color: #080;">&lt;-</span> supplements.<span style="">data</span><span style="color: #080;">&#91;</span><span style="color: #080;">!</span><span style="color: #0000FF; font-weight: bold;">is.<span style="">na</span></span><span style="color: #080;">&#40;</span>supplements.<span style="">data</span><span style="color: #080;">&#91;</span>,<span style="color: #ff0000;">2</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>,<span style="color: #080;">&#93;</span> <span style="color: #228B22;"># and we don't want any missing data</span>
&nbsp;
supplement.<span style="">score</span> <span style="color: #080;">&lt;-</span> supplements.<span style="">data</span><span style="color: #080;">&#91;</span>, <span style="color: #ff0000;">2</span><span style="color: #080;">&#93;</span>
ss <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">order</span><span style="color: #080;">&#40;</span>supplement.<span style="">score</span>, decreasing  <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">F</span><span style="color: #080;">&#41;</span>	<span style="color: #228B22;"># sort our data</span>
supplement.<span style="">score</span> <span style="color: #080;">&lt;-</span> supplement.<span style="">score</span><span style="color: #080;">&#91;</span>ss<span style="color: #080;">&#93;</span>
supplement.<span style="">name</span> <span style="color: #080;">&lt;-</span> supplements.<span style="">data</span><span style="color: #080;">&#91;</span>ss, <span style="color: #ff0000;">1</span><span style="color: #080;">&#93;</span>
supplement.<span style="">benefits</span> <span style="color: #080;">&lt;-</span> supplements.<span style="">data</span><span style="color: #080;">&#91;</span>ss, <span style="color: #ff0000;">4</span><span style="color: #080;">&#93;</span>
supplement.<span style="">score</span>.<span style="">col</span> <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">factor</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">as.<span style="">character</span></span><span style="color: #080;">&#40;</span>supplement.<span style="">score</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
	<span style="color: #0000FF; font-weight: bold;">levels</span><span style="color: #080;">&#40;</span>supplement.<span style="">score</span>.<span style="">col</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&lt;-</span>  <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;red&quot;</span>, <span style="color: #ff0000;">&quot;orange&quot;</span>, <span style="color: #ff0000;">&quot;blue&quot;</span>, <span style="color: #ff0000;">&quot;dark green&quot;</span><span style="color: #080;">&#41;</span>
	supplement.<span style="">score</span>.<span style="">col</span> <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">as.<span style="">character</span></span><span style="color: #080;">&#40;</span>supplement.<span style="">score</span>.<span style="">col</span><span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #228B22;"># mar: c(bottom, left, top, right) The default is c(5, 4, 4, 2) + 0.1.</span>
<span style="color: #0000FF; font-weight: bold;">par</span><span style="color: #080;">&#40;</span>mar <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">5</span>,<span style="color: #ff0000;">9</span>,<span style="color: #ff0000;">4</span>,<span style="color: #ff0000;">13</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>	<span style="color: #228B22;"># taking care of the plot margins</span>
bar.<span style="">y</span> <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">barplot</span><span style="color: #080;">&#40;</span>supplement.<span style="">score</span>, names.<span style="">arg</span><span style="color: #080;">=</span> supplement.<span style="">name</span>, las <span style="color: #080;">=</span> <span style="color: #ff0000;">1</span>, horiz <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">T</span>, <span style="color: #0000FF; font-weight: bold;">col</span> <span style="color: #080;">=</span> supplement.<span style="">score</span>.<span style="">col</span>, xlim <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">0</span>,<span style="color: #ff0000;">6.2</span><span style="color: #080;">&#41;</span>,
				main <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;Nutritional supplements efficacy score&quot;</span>,<span style="color: #ff0000;">&quot;(by evidence for its effectiveness on the listed condition)&quot;</span>, <span style="color: #ff0000;">&quot;(2010)&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">axis</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">4</span>, <span style="color: #0000FF; font-weight: bold;">labels</span> <span style="color: #080;">=</span> supplement.<span style="">benefits</span>, at <span style="color: #080;">=</span> bar.<span style="">y</span>, las <span style="color: #080;">=</span> <span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># Add right axis</span>
<span style="color: #0000FF; font-weight: bold;">abline</span><span style="color: #080;">&#40;</span>h <span style="color: #080;">=</span> bar.<span style="">y</span>, <span style="color: #0000FF; font-weight: bold;">col</span> <span style="color: #080;">=</span> supplement.<span style="">score</span>.<span style="">col</span> , lty <span style="color: #080;">=</span> <span style="color: #ff0000;">2</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># add some lines so to easily follow each bar</span></pre></td></tr></table></div>

<p>Also, the nice things is that if the guys at Information Is Beautiful will update there data, we could easily run the code and see the updated list of recommended supplements.</p>
<p><strong>Balloon plot</strong><br />
So after some web surfing I came around an implementation of a balloon plot in R (Thanks to <a href="http://addictedtor.free.fr/graphiques/graphcode.php?graph=60">R graph gallery</a>)<br />
There where two problems with using the command out of the box. The first one was that the colors where non informative (easily fixed), the second one was that the X labels where overlapping one another. Since there is no &#8220;las&#8221; parameter in the function, I just opened the function up, found where this was plotted and changed it manually (a bit messy, but that&#8217;s what you have to do sometimes&#8230;)</p>
<p>Here are the result (you can click the image for a larger image):</p>
<p><a href="http://www.r-statistics.com/wp-content/uploads/2010/02/balloonplot.png"><img src="http://www.r-statistics.com/wp-content/uploads/2010/02/balloonplot.png" alt="" title="balloonplot" width="550" class="alignnone size-full wp-image-199" /></a></p>
<p>And here is The R code to produce the Balloon plot of Nutritional supplements efficacy score (by evidence for its effectiveness on the listed condition).<br />
 (it&#8217;s just the copy of the function with a tiny bit of editing in line 146, and then using it)</p>
<p><span id="more-171"></span></p>

<div class="wp_codebox"><table><tr id="p1714"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code" id="p171code4"><pre class="rsplus" style="font-family:monospace;">&nbsp;
<span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>colorspace<span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>gplots<span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #228B22;"># I was able to find the function by using</span>
<span style="color: #228B22;"># methods(balloonplot)[1]</span>
<span style="color: #228B22;"># This command: getAnywhere(&quot;balloonplot.default&quot;) # Wouldn't work...</span>
balloonplot2 <span style="color: #080;">&lt;-</span> gplots<span style="color: #080;">:::</span><span style="">balloonplot</span>.<span style="">default</span> <span style="color: #228B22;"># This one works :)</span>
&nbsp;
<span style="color: #228B22;"># now run:</span>
<span style="color: #0000FF; font-weight: bold;">fix</span><span style="color: #080;">&#40;</span>balloonplot2<span style="color: #080;">&#41;</span>
<span style="color: #228B22;"># search for </span>
<span style="color: #228B22;"># y &lt;- ny + 0.75 + (nlabels.x - i + 0.5) * colmar</span>
<span style="color: #228B22;"># And add beneath it the following line:</span>
<span style="color: #228B22;"># y &lt;- rep(y, dim(xlabs)[1]) - c(0,.5,1)</span>
&nbsp;
supplement.<span style="">benefits</span> <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">tolower</span><span style="color: #080;">&#40;</span>supplement.<span style="">benefits</span> <span style="color: #080;">&#41;</span>
supplement.<span style="">name</span>		<span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">tolower</span><span style="color: #080;">&#40;</span>supplement.<span style="">name</span><span style="color: #080;">&#41;</span>
&nbsp;
balloonplot2<span style="color: #080;">&#40;</span> supplement.<span style="">name</span>,supplement.<span style="">benefits</span>, supplement.<span style="">score</span>, xlab <span style="color: #080;">=</span><span style="color: #ff0000;">&quot;supplement&quot;</span>, ylab<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;Benefit&quot;</span>,
			show.<span style="">margins</span><span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">F</span>, dotsize <span style="color: #080;">=</span> <span style="color: #ff0000;">15</span>,fun<span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">function</span><span style="color: #080;">&#40;</span>x<span style="color: #080;">&#41;</span><span style="color: #0000FF; font-weight: bold;">max</span><span style="color: #080;">&#40;</span>x,na.<span style="">rm</span><span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">T</span><span style="color: #080;">&#41;</span>,			
			rowmar <span style="color: #080;">=</span> <span style="color: #ff0000;">7</span>,
			colmar <span style="color: #080;">=</span> <span style="color: #ff0000;">7</span>,
			dotcolor <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">rev</span><span style="color: #080;">&#40;</span>heat_hcl<span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">max</span><span style="color: #080;">&#40;</span> supplement.<span style="">score</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#91;</span> supplement.<span style="">score</span><span style="color: #080;">-</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#93;</span>,
			main <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;Balloon plot of&quot;</span>, <span style="color: #ff0000;">&quot;Nutritional supplements efficacy score&quot;</span>,<span style="color: #ff0000;">&quot;(by evidence for its effectiveness on the listed condition)&quot;</span>, <span style="color: #ff0000;">&quot;(2010)&quot;</span><span style="color: #080;">&#41;</span>,
			<span style="color: #0000FF; font-weight: bold;">sub</span> <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;Published on www.r-statistics.com&quot;</span><span style="color: #080;">&#41;</span>				
			<span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p>Got any good ideas of how else to plot the data? let me know in the comments <img src='http://www.r-statistics.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.r-statistics.com/2010/02/nutritional-supplements-efficacy-score-graphing-plots-of-current-studies-results-using-r/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>

