<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/creating-figures-like-the-paper-completeness-of-digital-accessible-knowledge-of-plants-of-ghana-part-4/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://vijaybarve.wordpress.com/2016/12/13/creating-figures-like-the-paper-completeness-of-digital-accessible-knowledge-of-plants-of-ghana-part-4/"> Vijay Barve</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>This is the fourth part of the of the post where are going to create figure 4 Plot of Inventory Completeness against sample size for grid cells. <a target="_blank" rel="nofollow" href="https://vijaybarve.wordpress.com/2016/11/22/creating-figures-like-the-paper-completeness-of-digital-accessible-knowledge-of-plants-of-ghana-part-3/">Part 3</a> of this series we created chronohorogram for understanding seasonality by year of the data records.</p>
<p>If you have not already done so, please follow steps in <a target="_blank" rel="nofollow" href="https://vijaybarve.wordpress.com/2016/10/27/creating-figures-like-the-paper-completeness-of-digital-accessible-knowledge-of-plants-of-ghana-part-1/">Part 1</a> of the post to set up the data. Since this functionality was recently added to package bdvis, make sure <strong>you have v 0.2.9 or higher</strong> installed on your system.</p>
<p>The first step to generate this plot will be to compute completeness of the data. Package bdvis provides us with a handy function for that, as long as we want to compute the completeness for a degree grid. This was partially covered in an <a target="_blank" rel="nofollow" href="https://vijaybarve.wordpress.com/2016/06/10/visualize-completeness-of-biodiversity-data/">earlier blog post.</a></p>
<pre>
comp = bdcomplete(occ)
</pre>
<p>This command would return a completeness data matrix called comp and generate a plot of inventory completeness values (c) versus number of spices observed (sobs) in the data set as follows.</p>
<p><img sizes="(max-width: 490px) 100vw, 490px" data-image-description="" data-orig-file="https://i0.wp.com/vijaybarve.files.wordpress.com/2016/11/comp1.jpeg?w=456&amp;ssl=1" data-orig-size="600,600" data-image-title="comp1" class="wp-image-600" data-comments-opened="1" data-recalc-dims="1" data-attachment-id="600" data-permalink="https://vijaybarve.wordpress.com/2016/12/13/creating-figures-like-the-paper-completeness-of-digital-accessible-knowledge-of-plants-of-ghana-part-4/comp1/" alt="comp1" data-medium-file="https://i0.wp.com/vijaybarve.files.wordpress.com/2016/11/comp1.jpeg?w=456&amp;ssl=1?w=300" data-large-file="https://i0.wp.com/vijaybarve.files.wordpress.com/2016/11/comp1.jpeg?w=456&amp;ssl=1?w=490" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" src="https://i0.wp.com/vijaybarve.files.wordpress.com/2016/11/comp1.jpeg?w=456&ssl=1"></p>
<pre>
head(comp)
</pre>
<pre>   Cell_id nrec   Sobs  Sest      c
 1 35536   3436   243   276.3514  0.8793151
 2 35537   4315   299   318.7432  0.9380592
 3 35538   518    152   187.4118  0.8110483
 4 35896   17148  320   343.9483  0.9303724
 5 35897   7684   300   338.8402  0.8853732
 6 35898   865    169   216.7325  0.7797632</pre>
<p> </p>
<p>The data returned has cell identification numbers, number of records per cell, number of observed and estimated species and the completeness coefficient (c).</p>
<p>The default cut off number of records per grid cell is 50, but let us set that to 100 so we can filter out some grid cells which are data deficient.</p>
<pre>
comp = bdcomplete(occ, recs=100)
</pre>
<p>The graph we want to plot is Inventory Completeness (c) against sample size for grid cells (nrec) and not the one provided by default.</p>
<pre>
plot(comp$nrec, comp$c, main=&quot;Completeness vs number of species&quot;,
     xlab=&quot;Number of species&quot;, ylab=&quot;Completeness&quot;)
</pre>
<p>Will produce a graph like this:</p>
<p><img sizes="(max-width: 490px) 100vw, 490px" data-image-description="" data-orig-file="https://i2.wp.com/vijaybarve.files.wordpress.com/2016/11/comp21.jpeg?w=456&amp;ssl=1" data-orig-size="600,600" data-image-title="comp2" data-comments-opened="1" class="wp-image-634" data-recalc-dims="1" data-attachment-id="634" data-permalink="https://vijaybarve.wordpress.com/2016/12/13/creating-figures-like-the-paper-completeness-of-digital-accessible-knowledge-of-plants-of-ghana-part-4/comp2/" alt="comp2" data-medium-file="https://i2.wp.com/vijaybarve.files.wordpress.com/2016/11/comp21.jpeg?w=456&amp;ssl=1?w=300" data-large-file="https://i2.wp.com/vijaybarve.files.wordpress.com/2016/11/comp21.jpeg?w=456&amp;ssl=1?w=490" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" src="https://i2.wp.com/vijaybarve.files.wordpress.com/2016/11/comp21.jpeg?w=456&ssl=1"></p>
<p> </p>
<p>The problem with this graph is since there is very high variation in number of records per grid cell, majority of points having less than 5000 records are getting mixed up. So let us use log scale for number of records.</p>
<pre>
plot(log10(comp$nrec), comp$c, main=&quot;Completeness vs number of species&quot;,
     xlab=&quot;Number of species&quot;, ylab=&quot;Completeness&quot;)
</pre>
<p><img sizes="(max-width: 490px) 100vw, 490px" data-image-description="" data-orig-file="https://i0.wp.com/vijaybarve.files.wordpress.com/2016/11/comp3.jpeg?w=456&amp;ssl=1" data-orig-size="600,600" data-image-title="comp3" data-comments-opened="1" class="wp-image-638" data-recalc-dims="1" data-attachment-id="638" data-permalink="https://vijaybarve.wordpress.com/2016/12/13/creating-figures-like-the-paper-completeness-of-digital-accessible-knowledge-of-plants-of-ghana-part-4/comp3/" alt="comp3" data-medium-file="https://i0.wp.com/vijaybarve.files.wordpress.com/2016/11/comp3.jpeg?w=456&amp;ssl=1?w=300" data-large-file="https://i0.wp.com/vijaybarve.files.wordpress.com/2016/11/comp3.jpeg?w=456&amp;ssl=1?w=490" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" src="https://i0.wp.com/vijaybarve.files.wordpress.com/2016/11/comp3.jpeg?w=456&ssl=1"></p>
<p>Now this looks better. Let us change the x axis labels to some sensible values, to make this graph easy to understand. For that we will remove the current x axis labels by using xaxt parameter and then construct and add the tick marks and values associated.</p>
<pre>
plot(log10(comp$nrec),comp$c,main=&quot;Completeness vs number of species&quot;,
     xlab=&quot;Number of records&quot;,ylab=&quot;Completeness&quot;,xaxt=&quot;n&quot;)
atx &lt;- axTicks(1)
labels &lt;- sapply(atx,function(i) as.expression(bquote(10^ .(i))))
axis(1,at=atx,labels=labels)
</pre>
<p><img sizes="(max-width: 490px) 100vw, 490px" data-image-description="" data-orig-file="https://i0.wp.com/vijaybarve.files.wordpress.com/2016/11/comp4.jpeg?w=456&amp;ssl=1" data-orig-size="600,600" data-image-title="comp4" data-comments-opened="1" class="wp-image-652" data-recalc-dims="1" data-attachment-id="652" data-permalink="https://vijaybarve.wordpress.com/2016/12/13/creating-figures-like-the-paper-completeness-of-digital-accessible-knowledge-of-plants-of-ghana-part-4/comp4/" alt="comp4" data-medium-file="https://i0.wp.com/vijaybarve.files.wordpress.com/2016/11/comp4.jpeg?w=456&amp;ssl=1?w=300" data-large-file="https://i0.wp.com/vijaybarve.files.wordpress.com/2016/11/comp4.jpeg?w=456&amp;ssl=1?w=490" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" src="https://i0.wp.com/vijaybarve.files.wordpress.com/2016/11/comp4.jpeg?w=456&ssl=1"></p>
<p>Not let us add the lines to denote the cut off values of completeness we want to consider i.e. higher than 0.5 as inventory completeness values for cells having number of records greater than 1000.</p>
<pre>
abline(h = 0.5, v = 3, col = &quot;red&quot;, lwd = 2)
</pre>
<p><img sizes="(max-width: 490px) 100vw, 490px" data-image-description="" data-orig-file="https://i1.wp.com/vijaybarve.files.wordpress.com/2016/11/comp5.jpeg?w=456&amp;ssl=1" data-orig-size="600,600" data-image-title="comp5" data-comments-opened="1" class="wp-image-658" data-recalc-dims="1" data-attachment-id="658" data-permalink="https://vijaybarve.wordpress.com/2016/12/13/creating-figures-like-the-paper-completeness-of-digital-accessible-knowledge-of-plants-of-ghana-part-4/comp5/" alt="comp5" data-medium-file="https://i1.wp.com/vijaybarve.files.wordpress.com/2016/11/comp5.jpeg?w=456&amp;ssl=1?w=300" data-large-file="https://i1.wp.com/vijaybarve.files.wordpress.com/2016/11/comp5.jpeg?w=456&amp;ssl=1?w=490" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" src="https://i1.wp.com/vijaybarve.files.wordpress.com/2016/11/comp5.jpeg?w=456&ssl=1"></p>
<p>Now we may set the point size and shape to match the figure in paper by using pch and cex parameters. The final plot code will be as follows:</p>
<pre>
plot(log10(comp$nrec),comp$c,main=&quot;Completeness vs number of species&quot;,
     xlab=&quot;Number of records&quot;,ylab=&quot;Completeness&quot;,xaxt=&quot;n&quot;,
     pch=22, bg=&quot;grey&quot;, cex=1.5)
atx &lt;- axTicks(1)
labels &lt;- sapply(atx,function(i) as.expression(bquote(10^ .(i))))
axis(1,at=atx,labels=labels)
abline(h = 0.5, v = 3, col = &quot;red&quot;, lwd = 3)
</pre>
<p><img sizes="(max-width: 490px) 100vw, 490px" data-image-description="" data-orig-file="https://i2.wp.com/vijaybarve.files.wordpress.com/2016/11/comp6.jpeg?w=456&amp;ssl=1" data-orig-size="600,600" data-image-title="comp6" data-comments-opened="1" class="wp-image-662" data-recalc-dims="1" data-attachment-id="662" data-permalink="https://vijaybarve.wordpress.com/2016/12/13/creating-figures-like-the-paper-completeness-of-digital-accessible-knowledge-of-plants-of-ghana-part-4/comp6/" alt="comp6" data-medium-file="https://i2.wp.com/vijaybarve.files.wordpress.com/2016/11/comp6.jpeg?w=456&amp;ssl=1?w=300" data-large-file="https://i2.wp.com/vijaybarve.files.wordpress.com/2016/11/comp6.jpeg?w=456&amp;ssl=1?w=490" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" src="https://i2.wp.com/vijaybarve.files.wordpress.com/2016/11/comp6.jpeg?w=456&ssl=1"></p>
<p>If you have suggestions on improving the features of <a target="_blank" rel="nofollow" href="https://cran.r-project.org/web/packages/bdvis/index.html">package bdvis</a> please post them in issues in <a target="_blank" rel="nofollow" href="https://github.com/vijaybarve/bdvis/issues">Github repository</a> and any questions or comments about this post, please poth them here.</p>
<p><strong>References</strong></p>
<ul>
<li>Asase, Alex, and A Townsend Peterson. 2016. “Completeness of Digital Accessible Knowledge of Plants of Ghana.” Biodiversity Informatics, 1–11. doi:<a target="_blank" rel="nofollow" href="http://dx.doi.org/10.17161/bi.v11i0.5860">http://dx.doi.org/10.17161/bi.v11i0.5860.</a></li>
<li>Barve, Vijay, and Javier Otegui. 2016. “Bdvis: Visualizing Biodiversity Data in R.” Bioinformatics. doi:<a target="_blank" rel="nofollow" href="http://dx.doi.org/10.1093/bioinformatics/btw333">http://dx.doi.org/10.1093/bioinformatics/btw333</a>.</li>
</ul>
<p> <a target="_blank" rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vijaybarve.wordpress.com/582/"><img alt="" src="http://feeds.wordpress.com/1.0/comments/vijaybarve.wordpress.com/582/" border="0"></a> <img alt="" src="https://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" border="0" data-recalc-dims="1"></p>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://vijaybarve.wordpress.com/2016/12/13/creating-figures-like-the-paper-completeness-of-digital-accessible-knowledge-of-plants-of-ghana-part-4/"> Vijay Barve</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/LC43sbhBCg4"></a></div>