analysis and plotting in R