examples of r scripts and functions