miscellaneous r code