I need to install ggplot2 but keep getting an error:
Error in install.packages : cannot open file 'C:/Users/Patricia/Documents/R/win-library/3.5/file2a186f8351d5/glue/help/figures/logo.png': Permission denied
I have uninstalled and reinstalled R Studio and have run as administrator. Makes no difference.
That error can sometimes be caused by anti-malware software, including Windows Defender (usually the “Controlled Folder Access” anti-ransomware feature). You may need to whitelist R and RStudio, or (temporarily!) turn off the malware protection while you install.
It's turned out to be a temporary fix.... Received 2 more similar messages, different file names but otherwise the same structure. I decided to try to add the following to my Anti-Virus exception paths to see if it would get around it: C:/Users/Patricia/Documents/R/win-library/3.5/* - but it didn't work.
I was able to download another package without a hitch.... and Windows Defender has been turned off. Any advice appreciated, thanks.
I’m sorry you’re still having trouble! Unfortunately, we’re getting to the sort of really system-specific stuff that can be challenging to debug from afar. Some questions/things to try:
Are you running RStudio as administrator when you install packages, in addition to changing your anti-virus settings?
Since R moves things around a bit during installation (which can look suspicious to anti-malware software), you might try making the exclusion path the entire C:/Users/Patricia/Documents/R/ directory.
I have heard some people in this situation say they have more success installing packages (as administrator) from R, rather than from RStudio — not sure if that’s for real or not, but I guess it might look different from the perspective of the anti-malware program.
Are you on a computer where somebody else has influence over the anti-malware configuration (such as a work computer)? If so, you might need to talk to them.