Problem installing psych package

Hi,
I am new to R. I was trying to install a package on my Windows 7 PC but getting the following error. Please help.

install.packages("psych")
Installing package into ‘C:/Users/user/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
also installing the dependency ‘mnormt’

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/mnormt_1.5-5.zip'
Content type 'application/zip' length 102302 bytes (99 KB)
downloaded 99 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/psych_1.8.3.3.zip'
Content type 'application/zip' length 5727743 bytes (5.5 MB)
downloaded 5.5 MB

Error in install.packages : cannot open file 'C:/Users/user/Documents/R/win-library/3.4/file17244fd07ed8/mnormt/CITATION': Permission denied

The error reported is related to the installation of psych dependency, mnormt.
Particularly, it's a permission problem to write the CITATION file in a temporary directory.
This is strange and unusual, since you shouldn't have problems to write temporary files.
And this looks more strange to me because, if the error is really being caused by the writing of CITATION, well, this is a text file.
Some machines, particularly corporate machines, have restrictions on writing binary files.
This might not be the case.
I can only suggest you to see if you have enough space.

Install the package in a R session with administrative privilege:

It might be possible to do this in RStudio, but it is simpler to do it directly in R. On windows, right click your R shortcut and select "Run as administrator". Then install your package as usual.

Thank you sir,
I could install "psych" package in R with administrative right but I also need it in RStudio to work.

Now again when I tried to install in RStudio following errors came:

install.packages("psych")
Installing package into ‘C:/Users/user/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/psych_1.8.3.3.zip'
Content type 'application/zip' length 5727743 bytes (5.5 MB)
downloaded 5.5 MB

Error in install.packages : cannot open file 'C:/Users/user/Documents/R/win-

library/3.4/file84c2bb32a7/psych/CITATION': Permission denied

this time error regarding dependency ‘mnormt’ did not show.

Please help

RStudio is an IDE for R. You don't need to install it in RStudio. Installing it in R will allow you to access it whenever you use R (including when you use R from RStudio).

So your problem should now be fixed.

Whenever you have permission issues while installing or updating packages, do the same: open R with administrative privilege and update/install your packages.

After that, you can close this R session and launch RStudio if you usually run R in RStudio. The packages will be installed/updated and work.

Thank you sir........
it was installed and it is working now.... thank you once again for your prompt help.

You're very welcome :slight_smile: I'm glad I could help.