<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/merry-christmas-2/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://blog.revolutionanalytics.com/2016/12/merry-christmas.html"> Revolutions</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<p>Christmas day is soon upon us, so here's a <a target="_blank" rel="nofollow" href="http://www.data-imaginist.com/2016/Data-driven-x-mas-card/">greeting made with R</a>:</p>
<p><a target="_blank" rel="nofollow" href="http://revolution-computing.typepad.com/.a/6a010534b1db25970b01bb0962c140970d-pi"><img title="MerryXmas" alt="MerryXmas" src="http://revolution-computing.typepad.com/.a/6a010534b1db25970b01bb0962c140970d-800wi" border="0"></a></p>
<p>Each frame is a <a target="_blank" rel="nofollow" href="https://en.wikipedia.org/wiki/Voronoi_diagram">Voronoi Tesselation</a>: about 1,000 points are chosen across the plane, which each generate a polygon comprising the region closer to it than any other selected point. These process is repeated for three designs (a heart, the word &quot;Merry&quot;, and the word &quot;Xmas&quot;), and the Voronoi tiles are colored according to whether the generating point is within the design. In the transitions between the designs, the points migrate from one selected point in one design to a selected counterpoint in the next. The counterpoint is randomly chosen for the &quot;heart&quot; transition (generating a chaotic assembly effect); and a nearby point is chosen for the &quot;Merry&quot; transition (for a much smoother effect).</p>
<p>There's some interesting R-based magic behind how the animation was created as well. The three designs were created in Adobe Illustrator. Getting shapes from Illustrator into R is a surprisingly simple two-line process: you simply import the design using <a target="_blank" rel="nofollow" href="https://www.rdocumentation.org/packages/rjson/versions/0.2.15/topics/fromJSON">fromJSON</a>, and extract the component representing line segments which can be immediately drawn in R.  The tesselations were drawn using the <code>geom_voronoi_tile()</code> ggplot2 geom in the <a target="_blank" rel="nofollow" href="https://github.com/thomasp85/ggforce">Github version of the ggforce package</a>, and colored by checking whether the generating point falls inside the design using the <code><a target="_blank" rel="nofollow" href="https://www.rdocumentation.org/packages/mgcv/versions/1.8-16/topics/in.out">in.out</a></code> function of the <a target="_blank" rel="nofollow" href="https://mran.microsoft.com/package/mgcv/">mgcv package</a>. The smooth transition of the generating points from one design to the next were calculated using the <a target="_blank" rel="nofollow" href="https://mran.microsoft.com/package/tweenr/">tweenr package</a>, and the whole thing was animated using the <a target="_blank" rel="nofollow" href="https://mran.microsoft.com/package/animation/">animation package</a>.</p>
<p>For the complete details on how this lovely greeting was created, including the R code, follow the link to creator Thomas Lin Pedersen's blog post below.</p>
<p>Data Imaginist: <a target="_blank" rel="nofollow" href="http://www.data-imaginist.com/2016/Data-driven-x-mas-card/">Data Driven Christmas Card Animation with Voronoi Tiles</a></p>
</div>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://blog.revolutionanalytics.com/2016/12/merry-christmas.html"> Revolutions</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/7i2XlXb-ljU"></a></div>