Skip to content

installed.packages() with no packages

2 messages · Jeff Gentry, Peter Dalgaard

#
Hello ...

I found this due to a situation where installed.packages() was given a
lib.loc argument that turned out to not have any R packages installed.  As
an example:
Error in "colnames<-"(*tmp*, value = c("Package", "LibPath", pkgFlds)) : 
	dimnames applied to non-array

Looking at the code, it seems what happens is that 'retval' is assigned
character() but then after the for loop the function checks 'retval' with
a "if(!is.null(retval))", and I don't see how 'retval' could ever have a
NULL value in this situation.  Would this be better to check against
"nrow(retval)"?

Thanks
-Jeff
#
Jeff Gentry <jgentry@jimmy.harvard.edu> writes:
Or change the initialization to retval <- NULL as would seem to have
been intended? Seems to work OK.