Package Autoloading due to syntax checking

When does R Studio autoload packages?

The above question has been closed, but I have more information. R Studio seems to autoload packages if the full package reference is used.
For example, I am using the SeuratDisk package. If my code is the following:
seuratData <<- LoadH5Seurat(...)
Nothing happens, but if I add the package specification:
seuratData <<- SeuratDisk::LoadH5Seurat(...)
The package gets loaded without running the program. I can see in the console that the package is loaded as soon as highlighting/code analysis occurs.

This is problematic because I need to use a custom library in a non-default path, but the autoloaded library comes from the default directory.
Please don't autoload packages.

would explicitly loading the package from the path you specificy solve your issue ?

library(SeuratDisk,lib.loc = )
seuratData <<- SeuratDisk::LoadH5Seurat(...)

Unfortunately, that doesn't make a difference because the library call is not executed until the program is run. If I make sure to load the library before the SeuratDisk:: code is written, it is OK, but I don't think I should have to do that.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.