Posts Tagged ‘ how to ’

Interacting with bioinformatics webservers using R

September 8, 2011
By
Interacting with bioinformatics webservers using R

In an ideal world, all bioinformatics tools would be made available via the Web as a web service with an API, as well as a standalone package to download for local use. This is rarely the case and sometimes, even where one or the other is available, factors such as cost come into play. So

Read more »

R: calculations involving months

July 7, 2011
By
R: calculations involving months

Ask anyone how much time has elapsed since September last year and they’ll probably start counting on their fingers: “October, November…” and tell you “just over 9 months.” So, when faced as I was today with a data frame (named dates) like this: How to add a 7th column, with the number of months between

Read more »

R 2.12 to 2.13 package upgrade

April 14, 2011
By
R 2.12 to 2.13 package upgrade

If you: use Linux have just upgraded your R installation from 2.12 to 2.13 installed some/all of your packages in your home area (e.g. ~/R/i486-pc-linux-gnu-library/2.12) and… …are wondering why R can’t see them any more just do this: # at a shell prompt cp ~/R/i486-pc-linux-gnu-library/2.12 ~/R/i486-pc-linux-gnu-library/2.13 # in R console update.packages(checkBuilt=TRUE, ask=FALSE) # back to

Read more »

Use R to view and manipulate the File System

February 21, 2011
By

One of the best ways to learn how to code in R is to view sample scripts that people share. I recently came across this post where Michael uses R to scrape twitter and collect all sorts of great data … Continue reading →

Read more »

Visualize NHL Play-by-Play using Tableau Public and R

February 13, 2011
By
Visualize NHL Play-by-Play using Tableau Public and R

Nothing like a little Sunday morning data hacking before a big game!  I have been wanting to play with the NHL play-by-play event files for some time now.  The JSON datasets provide a wealth of information about each event in the game including the location, as defined by the fields xcoord and ycoord. I am

Read more »

The Clipboard can be Your Friend

January 17, 2011
By
The Clipboard can be Your Friend

One of the features I feel that I don’t leverage enough, particularly for ad-hoc questions, is the clipboard feature  in R. I know there are many ways to use it –  as I have been exposed to a few –  but the example below, even without context, should get you thinking about how awesome R

Read more »

Remove all rows of an R dataframe

January 13, 2011
By
Remove all rows of an R dataframe

I should have probably figured this out a long time ago, but as I get deeper into programming with R, I am finding the need to remove all rows from a dataframe.  I was making this alot harder than it had to be. your.df<- your.df Replace your.df with, your dataframe and you are good

Read more »

Scrape Web data using R

August 13, 2010
By
Scrape Web data using R

Plenty of people have been scraping data from the web using R for a while now, but I just completed my first project and I wanted to share the code with you.  It was a little hard to work through some of the “issues”, but I had some great help from @DataJunkie on twitter. As

Read more »

Read Compressed Zip Files in R

June 25, 2010
By
Read Compressed Zip Files in R

One of the great things that I am learning about R is that it is really powerful as a data management tool.  I just found how to unzip files.  I could use Python for this in SPSS, but it just feels like it is more natural to do in R.  Of course, you have to

Read more »

Plotting “time of day” data using ggplot2

April 14, 2010
By
Plotting “time of day” data using ggplot2

William asks: How can I make a graph that looks like this, “tweet density” style, showing time intervals? He then helpfully describes his input data: a CSV file with headers “time started, time finished, date”. Here’s a simple CSV file, tasks.csv: task,date,start,end task1,2010-03-05,09:00:00,13:00:00 task2,2010-03-06,10:00:00,15:00:00 task3,2010-03-06,11:00:00,18:00:00 task4,2010-03-07,08:00:00,11:00:00 task5,2010-03-08,14:00:00,17:00:00 task6,2010-03-09,12:00:00,16:00:00 task7,2010-03-10,14:00:00,19:00:00 task8,2010-03-11,09:30:00,13:30:00 Read into R, calculate the

Read more »