I have multiple versions of R running side by side, switchable from Rstudio. I tried your method and it installs packages in the oldest version of R. Even if I put the newest version in the PATH, sudo -i R always picks up the oldest R. Is there fix for this? Thanks