From szehnder at uni-bonn.de  Mon Sep  9 10:22:32 2013
From: szehnder at uni-bonn.de (Simon Zehnder)
Date: Mon, 9 Sep 2013 10:22:32 +0200
Subject: [Rd] Package installation and path.package
Message-ID: <79265780-D119-450A-93F9-D5BA2A81C9B1@uni-bonn.de>

Dear R-Devels,

I am writing right now my own package that makes use of 'tempfile' and there within with 'path.package'. When I install it, I get the error: Error in path.package("mypackage") : none of the packages are loaded. Here is the code, I use in my package:


".defaultDBPath"    <- function() 
{
    db.path <- tempfile(pattern     = "mmstructDB", 
                        tmpdir      = file.path(path.package("mmstruct"),
                                                "data", "databases"),
                        fileext     = ".db")
    return(db.path)
}

.mmstructBASE <- setClass("mmstructBASE",
                          		    representation("VIRTUAL",
                                                                    dbName     = "character",
                                                                    dbTable    = "character"),
                                            prototype(dbName      = character(),
                                                            dbTable     = character()
							    )
)

.mmstructDB <- setClass("mmstructDB",                        
                        representation("VIRTUAL",
                                       conn = "SQLiteConnection"),
                        contains = c("mmstructBASE"),
                        prototype(conn  = dbConnect(dbDriver("SQLite"), .defaultDBPath()))
)

I understand the error, but I would like to have a workaround. How can I give the path to the package I am actually installing without getting this error? 


Best

Simon


[Rd] Package installation and path.package
Simon Zehnder