Skip to content
Prev 16010 / 21307 Next

[Bioc-devel] How to use RData files in Bioconductor data and software packages

Hi Richard,

It depends on the filetype. I am loading my "non RData" files with 
read.delim and my RData files with a helper function which returns a R 
object of the RData object:

#' Load RData object and returns first entry
#'
#' Load RData object and returns first entry. If there is more than one
#' object in the RData file, only the first object will be returned.
#'
#' @param RDataFile a \code{character} vector to the RData file.
#'
#' @return The \code{R} object of the RData file.
#' @export
#' @examples
#' # load GRanges object stored in a RData file.
#' dummy.GRanges <- loadRData(system.file('extdata', 'dummy.RData', 
package = "dummyData"))
loadRData <- function(RDataFile) {
 ? load(RDataFile)
 ? objectToLoad <- ls()[ls() != "RDataFile"]
 ? if (length(objectToLoad) > 1)
 ??? warning(paste0("RData file contains more than one object. Only the 
first object (",
 ?????????????????? objectToLoad[1], ") will be returned!"))
 ? get(objectToLoad[1])
}

I know this is not the best solution. I guess saving the R objects in 
RDS files instead of RData files is the better solution here.

My question is if my storage of the RData objects (or RDS objects) in 
the inst/extdata directory is ok for an Bioconductor package.

Best,

Tobias


Am 09.01.20 um 15:45 schrieb Richard Virgen-Slane: