miscellaneous codebits mostly in R I have written