Trouble installing package "xlsx"


I am new to the community, and I hope I am reaching out in the proper channel, and I hope that this is not a redundant topic:

I am trying to install the xlsx package in R Studio, and I continue to get the following error when I try to run library("xlsx").

> install.packages("xlsx")
Installing package into ‘C:/Users/annar/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
trying URL ''
Content type 'application/zip' length 405569 bytes (396 KB)
downloaded 396 KB

package ‘xlsx’ successfully unpacked and MD5 sums checked
Warning in install.packages :
  unable to move temporary installation ‘C:\Users\annar\Documents\R\win-library\3.4\file60c528077f0\xlsx’ to ‘C:\Users\annar\Documents\R\win-library\3.4\xlsx’

The downloaded binary packages are in
> library("xlsx")
Error in library("xlsx") : there is no package called ‘xlsx’

As a true novice to R programming, I am stumped. Could someone please shed some light as to how I might move forward from this?

Thank you,

1 Like

Hi! Welcome!

The installation is getting stuck at the point when R tries to move the downloaded package files from a temporary directory into your R library.

The most common reason for this problem seems to be anti-virus/anti-malware software preventing files from being moved within your User directories (which is where your R library lives). This is usually meant as protection against ransomware.

As a test, you could try temporarily turning off any anti-malware software you are running, and then try installing again. If it works, then you’ll need to figure out how to change settings in the anti-malware software to remove these restrictions from RStudio and R. There are some pointers for a few popular anti-malware software packages in the comments on this StackOverflow answer:

P.S. It is unlikely this problem has to do with the RStudio IDE, so I’m moving the post to a different category to cut down on noise in the #rstudio-ide channel. You also have the power to recategorize your posts: FAQ: How Do I Change Categories, Tags, and Title?


@jcblum ,

Thank you so much for the tip! I am currently working with R on my work laptop, so I will contact my IT department to fiddle around with the anti-virus settings. Once I have tested this, I will update you with my results.

Also, thank you for moving the post to the appropriate category, and for the helpful FAQ link.


1 Like


UPDATE: The StackOverflow thread provided me with a workaround! I entered this code


And followed the directions to "step through the code (by pressing enter many times)", and now I can use the read.xlsx() function!

Also, thank you to @tbradley for formatting my code text in my original post! I have made an effort to format the code text in this reply, and I hope it suffices.

Thank you for the support you guys!



Your code formatting in your reply is exactly what we are looking for! Thanks for taking the time to do it!

I am glad you found the answer to your question! If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

1 Like

Got it - thanks for keeping me organized!

1 Like

Thanks for your post Anna marie!
I was trying it with the dplyr package but haven't been successful, have you tried your method with it?