R vs Processing

We have been tasked with showing visual data from a flocking simulation so that someone can tweak variables that affect the way the simulation runs with some insight. Suggestions were things such as spitting out a CSV and making graphs in Excel and Heatmaps. I will be completing Heatmaps, but instead of graphing in Excel, I decided I would look into R and Processing.

After doing a bit of research on both, I found a useful video on how to make a graph in R, so I took that option first. I downloaded and installed R, got myself an IDE (R studio) and started playing around with R. The way you run R in the IDE is different to anything I have done before. It only runs lines that are highlighted, mean you can run a single line in your program or you can highlight it all and run the whole application.

I downloaded a library for R called ggplot2. This library was created to easily plot data from a table. To create the table, I loaded in a CSV. Reading CSVs in R is so simple. They have a function specifically for reading them in, and once you have the table, to get data from a specific cell you just have to write the variable name then the heading or index next: table$heading1.

After creating a bar graph, I ran into my first problem. This was running in the IDE and was only showing one Graph at a time. So I decided to try and export the program to see what it does as a .exe…. however, that isn’t an option (as far as I could tell). All solutions I found said you could write another program to launch your R code as it’s an interpretive language, but you also need R installed on the deployment machine. This was the biggest killer as I plan on running this on Uni Computers where R isn’t installed. There is also the fact that I would never want to ask people to install R just to see some graphs that could have been done (and probably nice looking) in Excel. That leaves Processing.

Before even diving into finding libraries for processing that make graphs, I determined if you could export it as an .exe. And you can! So this is off to a good start. Another really good thing about processing is you don’t need to install it, so it can be ran anywhere. You just need the .exe you download and you are good to go.

After a bit more research through all the libraries, I found once called giCenterUtils. It seemed to do exactly what I wanted, so I pulled the library into processing, and tried it out. I parsed my CSV file and passed all the lifetimes of the prey to a barchart. Then I specified where I wanted it and voila, there is a nice bar graph on my screen. The following picture shows the lifetimes of the prey in a bar graph form then displayed 4 times. That way once I have recorded more data, I will be able to show various plots on the screen.

Processing

My plan from here is to add titles to the graphs then have arrows on the sides of the screen so you can go between the graphs, allowing for more than 4 graphs to be shown.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s