R graphics and data munging