X-Mas Tree with 10 Lines of R Code

Besides the many negative aspects of going through a pandemic, there are also certain positive ones like having time to write short blog posts like this.

This one picks up a topic that was intensively discussed a couple of years ago on Wolfram’s page: Namely that the damped sine wave

f(t) = t sin(t)

can be used to draw a Christmas tree. Throw in some 3D animation using the R package rgl and the tree begins to become virtual reality…

Here is our version using just ten lines of R code:

R
Exported as gif using magick

Christian and me wish you a relaxing time over Christmas. Take care of the people you love and stay healthy and safe.

Code and animation can be found on github.

Comments

3 responses to “X-Mas Tree with 10 Lines of R Code”

  1. susan hilsenbeck Avatar
    susan hilsenbeck

    Thanks for the christmas tree. Super cool.

    1. Michael Mayer Avatar

      Thanks! And (almost) fully sustainable compared to a real one.

  2. […] Michael Mayer has a festive post: […]

Leave a Reply

Your email address will not be published. Required fields are marked *