Вопрос

I want to put the following function in my .Rprofile to make installation of bioconductor packages easier:

install.bioconductor <- function(...) {
  source("http://bioconductor.org/biocLite.R")
  biocLite(...)
}

But when I load a new R session, this function is now listed when I call ls. Is there a way of masking the function from being shown?

Это было полезно?

Решение

You can put it in its own environment and attach that environment to the search path.

myFUNs <- new.env()
myFUNs$install.bioconductor <- function(...) {
  source("http://bioconductor.org/biocLite.R")
  biocLite(...)
}
attach(myFUNs) # attach to the search path
rm(myFUNs)     # remove from .GlobalEnv

# it is still accessible via 
# install.bioconductor(...)

Then it be accessible, but will not show up in ls(). (You can see what is attached to the search path with search(), and you can see what is in myFUNs with ls(myFUNs))

Alternatively, as @JoshuaO'Brien mentioned in a comment you can keep it in the .GlobalEnv but add a dot to the beginning of the name (i.e. name it .install.bioconductor) so that it will be "hidden" such that it won't show up with ls(), but will show up with ls(all.names=TRUE).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top