On Sep 9, 2013, at 4:22 AM, Simon Zehnder wrote:

> 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? 
> 

That path to your package is dynamic - in general it will not be know when 
creating the lazy-load DB, so you really want to put that code in .onLoad() 
where the path is known.

Cheers,
Simon


> 
> Best
> 
> Simon
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to