Posts

Showing posts from July, 2017

Shortcuts to making your R code run faster! Part 1

The goal of running code is usually to make tasks easier, faster, and more efficient. Sometimes however, it may feel like you are always waiting for your code to run. We will go through a few fun tips that can help speed up that process. 1. Preset your vector or Matrix destinations. Believe it or not that presetting your vector destinations saves your code a lot of running time. This is because when you run a loop or a function and you don't preset your destination R has to hold those variables in its cache memory, however, if you have preset vector ready for variables the values will be routed to that vector. Take this simple example below for instance: # Creating a destination with non-specific number of variables for output vector X = c () # Start timing the loop Strt <- Sys.time () for (i in 1 : 100000 ){ X[i] = i } print ( Sys.time () - Strt) # Print how long it takes to run the loop ## Time difference of 8.179752 secs Ok lets try it with a m

Creating Your Own .gifs! Part 2

Image
This week we are going finish our Creating your own .gif fun. So last blog we were able to make a gif using ImagJ and R. Using this method has its pro's and con's. Pro's you can use ImageJ to edit your images as you see fit. Con's you have to do additional steps outside of R. So today's post we will use R and ImageMagic. These steps will allow you to create a .gif without leaving R for additional steps.  Now I saved this post for last because it it slightly more complicated to install ImageMagic. It took me several weeks searching bog post, stack flow posts, and any other tutorials to figure out how to download and run ImageMagic properly. When most people do posts on creating .gifs they leave out the importance of downloading and running ImageMagic. And even if they did it was either for Windows or Mac but never both. SO.... I will be take the time to explain how to install it for both Mac and Windows (I'm sorry Linux users I'm not there yet). ~~~~~~~~~~~