Publications by nzcoops

Forest plots in R (ggplot) with side table

06.11.2012

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). Some other options for forest plots included this: From Abhijit blog. But I figured I’d sta...

1550 sym Python (102 sym/1 pcs) 12 img

ggplot graphs in publications?

06.11.2012

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...

3181 sym 4 img

Updated age calculation function

12.06.2013

I had previously posted a function for calculating age with two dates. This was for the whole number ‘age’ where we are assuming you don’t want someone to be recorded as ’18′ until their 18th birthday (so more than just YEAR – YEAR). There was an error in the code when a certain combination was entered, so I’ve rewritten it, and thi...

1230 sym 4 img

ggplot + powerpoint = wall + head … solution?

02.09.2013

Confession, by ‘solution?’ I literally mean I’m asking for your thoughts on a solution. Like it or lump it I do a lot of graphs for presentations, largely in powerpoint. That’s the way my colleagues/industry work(s) and it’s not about to change anytime soon. I have a real frustration with getting my plots out and into powerpoint. What a...

3603 sym 4 img

Finding the midpoint when creating intervals

23.05.2014

Nothing ground breaking here. I was doing some work dividing data into deciles and then creating some plots. I couldn’t find an function to calculate this from cut, and I use cut quite a bit. So here we are. midpoints lower upper return(round(lower+(upper-lower)/2, dp)) } And in an example: midpoints lower upper return(round(lower+(upper...

1994 sym 4 img

Shading between two lines – ggplot

01.06.2014

First one to say geom_ribbon loses. I was plotting some data for a colleague, had two lines (repeated experiment) per person (time on the x axis) facetted by id, I thought it’d be nice to shade the area between the two lines so that when they were deviating you’d see a large shaded area, and when they were close there would be little shading,...

2290 sym R (2860 sym/3 pcs) 8 img