<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/spinning-pins/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://fronkonstin.com/2018/12/19/spinning-pins/"> R – Fronkonstin</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div class="twitter-share"><a rel="nofollow" href="https://twitter.com/intent/tweet?url=https%3A%2F%2Ffronkonstin.com%2F2018%2F12%2F19%2Fspinning-pins%2F&via=aschinchon" class="twitter-share-button" target="_blank">Tweet</a></div>
<blockquote class="wp-block-quote">
<p>Condenado a estar toda la vida, preparando alguna despedida (Desarraigo, Extremoduro)</p>
</blockquote>
<p>I live just a few minutes from the <a rel="nofollow" href="http://www.muncyt.es/" target="_blank">Spanish National Museum of Science and Technology (MUNCYT)</a>, where I use to go from time to time with my family. The museum is plenty of interesting artifacts, from a portrait of Albert Einstein made with thousands of small dices to a wind machine to experiment with the Bernoulli’s effect. There is also a device which creates waves. It is formed by a number of sticks, arranged vertically, each of one ending with a ball (so it forms a sort of pin). When you push the start button, all the pins start to move describing circles. Since each pair of consecutive pins are separated by the same angle, the resulting movement imitates a wave. In this experiment I created some other machines. The first one imitates exactly the one of the museum:</p>
<div class="wp-block-image">
<figure><img alt="" src="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2018/12/pins_1.gif?w=604&ssl=1" data-recalc-dims="1"></figure>
</div>
<p>If you look carefully only to one pin, you will see how it describes a circle. Each one starts at a different angle and all them move at the same speed. Although an individual pin is <em>pretty boring</em>, all together create a nice pattern. The museum’s machine is formed just by one row of 20 pins. I created a 20×20 grid of pins to make result more appealing.</p>
<p>Playing with the angle between pins you can create another nice patterns like these:</p>
<div class="wp-block-image">
<figure><img data-orig-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2018/12/pins_2.gif?fit=480%2C480&amp;ssl=1" data-orig-size="480,480" data-medium-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2018/12/pins_2.gif?fit=300%2C300&amp;ssl=1" data-attachment-id="4748" data-image-meta="{" data-image-description="" src="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2018/12/pins_2.gif?w=604&ssl=1" data-permalink="https://fronkonstin.com/2018/12/19/spinning-pins/pins_2/" data-large-file="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2018/12/pins_2.gif?fit=480%2C480&amp;ssl=1" alt="" data-image-title="pins_2" data-comments-opened="1" class="wp-image-4748" data-recalc-dims="1"></figure>
</div>
<div class="wp-block-image">
<figure><img alt="" src="https://i0.wp.com/fronkonstin.com/wp-content/uploads/2018/12/pins_3.gif?w=604&ssl=1" data-recalc-dims="1"></figure>
</div>
<div class="wp-block-image">
<figure><img alt="" src="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2018/12/pins_4.gif?w=604&ssl=1" data-recalc-dims="1"></figure>
</div>
<p>The code is incredibly simple and can be used as a starting point to create much more complicated patterns, changing the speed depending on time or the location of pins. Play with colors or shapes of points, the number of pins or with the separation and speed of them. The magic of movement is created with <code>gganimate</code> package. You can find the code <a rel="nofollow" href="https://github.com/aschinchon/spinning-pins" target="_blank">here</a>.</p>
<p>Merry Christmas and Happy New Year. Thanks a lot for reading my posts.</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://fronkonstin.com/2018/12/19/spinning-pins/"> R – Fronkonstin</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 rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/op25b4WkGeY" height="1"></a></div>