The grey background and/or default choice of colours for groups makes a ggplot graph stand out to any R user when seen in a presentation. But ggplot graphs get all ninja when it comes to publications, either that or not a lot of graphs generated using ggplot have been published in the journal I read (health research (epidemiology/diabetes largely). Like many others ggplot is my go to graphing package and I’ve prepared graphs using ggplot that have been published in the past.
Forest plots in R (ggplot) with side table
A friend asked me to help with a forest plot recently. After chatting about what she wanted the end result to look like, this is what I came up with.
grid.arrange(data_table, p, ncol=2)## Warning: Removed 1 rows containing missing values (geom_point).
Popularity indicator, with images (NFL)
It’s Friday night, there’s nothing good on TV, mmm conditions are perfect for shaggin about in R. So I’m an NFL fan, and (shameless plug) avid fan of this NFL podcast. They run their own pickem league which unless users opt out shows their tips in a table. You can eyeball it and get a feel for who picked what, but naturally I wasn’t too fond of just eyeballing the data. So that was my Friday night motivator for this project. At work (among other things) I’m working on using knitr to automate some reports for live reporting of uploaded data, I thought (potentially when polished) the NFL Rants and Raves site could could use this on their pickem site.
Simple plot with text boxes
Was doing a little presentation to our research group and had to explain the difficulties of ‘collapsing’ longitudinal data into a single measure when the Y var is quite variable. For the particular Y var of interest, it represents burden of disease, so a high Y var for a long time is indicative of high risk, compared to a low value for a similar time. Hence you have issues using with the mean, or the AUC. There’s a lot more to it than that, but that’s the gist of the point of this graph. Sharing the code cause it might be useful to someone else at some point.
(Manually) making letters with geom_path() – fun example
Disclaimer, maybe the title should be ‘lame example’.
Nothing overly exciting here. Just posting cause it took a little faffing about and someone else might like the idea. At my work (research institute) we (the social club committee) were organising an ‘Olympics event’ with a bunch of task for teams of 4, with a loose research theme. I thought a graphing race could work, and was trying think how it could be made a little more fun than drawing a line.
Petrol prices adjusted for inflation
Petrol prices adjusted for inflation (Perth, Western Australia)
The thought for this sprung to mind when I saw petrol drop below $1.20 per litre the other day, and it made me think, I remember paying that when I got to Australia 4.5 years ago. Fuel prices are listed online here, so I went to the site for a nosey at their archiving and they have a reasonably comprehensive archive of data – WA historic fuel prices. All that was left to do was hunt out the inflation (CPI) data, which was also readily available – Australian inflation data.
The fuel price data was available as a monthly average [for the Perth Metro area]. The inflation data was available quaterly. Given the fuel data started in 2001, I thought it made sense to show things in 2001 dollars, so I divided the indices by the 2001 indices to make this the baseline. For manipulation purposes I converted the month data into date data, using the 1st of the month for the day in all cases. Then the ‘closest’ inflation index was merged onto the fuel price, which was then converted into 2001 dollars, and graphed.
LME summary data – results table
UPDATE: Based on the comment from ‘linuxizer’, I’ve updated this to stay inline with the S3 classes, something I didn’t have my head around at the time, still don’t know it inside out.
Brief post.
One thing I do often in my analysis is use things like ‘summary(mod)$coefficients’ and variance derivatives of that to pull the results from models into table so I can write my results nicely to csv, which can then be circulated to colleagues. I take the time to do this, so that when I go back and subset the data someone, I can instantly generate the same, nice, tailored results table. As it is often the case that you will run analysis multiple times, perhaps subsetting on years, or ages or subjects etc etc.
