Wednesday, July 22, 2015

[Humor] Movement of organisms across a 5x4 Grid (A work in progress)


Imagine you have 8 lady beetles moving across a 5 x 4 grid. 
You assume that at each time-step, the beetle would either stay in place or move in a cardinal direction (N,W,S,E). 
Basically you just want to see how lady beetles move across a grid.
It should be simple.
It should be simple.
It is simple.
But it wasn't for me! And to be honest, I shouldn't be surprised as I still consider myself a novice in the world of R.

My first attempt is horrific.
Basically I created a 5x4 matrix and I looped through each element of the matrix and ran a function.
It didn't work. Somehow the lady-beetles got up to a million (I did not code this in) and was slow. I called this the shame-code.

"The horror, the horror"

In the video game, Far Cry 3, the main antagonist defined insanity as doing the same thing over and over expecting something to change. It's really hard to realize that your code that you worked hours on is never going to work.  It's even harder to let it go. My first code took me some days to write. The code I am presenting is my work from 12:00 pm to 6:00 pm on a lazy Wednesday afternoon. 


Raster is a great package everyone.



Here is the code! I'm still checking to see if it actually works (so grain of salt) 

<script src="https://gist.github.com/damiepak/bdeaeb963e7d223449bb.js"></script>

Wednesday, July 1, 2015

Birds Birds Birds!


Had a barbecue with the family. Birds everywhere.



Hungry baby birds