Can't access User Library in R - "Non-Zero Exit Status" warning

A non-zero exit status means in this case that the system failed to install the package. There seem to be a number of unresolved dependencies in the installation process. You could try to resolve this by attempting to install the package using the option dependencies=TRUE; like this:

install.packages("ggplot2", dependencies=TRUE)

i was struggling with the same problem, for a long time and mikes solution didnt help me either. I tried everything upto reinstalling R. Still didnt work. However the solution is quite simple in my case. In the Terminal dont run R as R but use:

sudo -i R

or change ownership of the r package folders, becaues if its owned by root you are not allowed to read or write in it.