Function for upgrading R and saving packages