Function to require a R package and install it if needed.