Alright, first attempt at writing an R package and I'm stuck. Here's how I create the package:
package.skeleton("pkg",code_files=some.filenames)
roxygenize("okg")
I'm using roxygen2 and have the following imports in my "pkg-package.R" file:
@import data.table zoo lubridate
From a terminal, I then run:
R CMD build pkg
R CMD check pkg
R CMD install pkg
During the check phase, I get the following warnings:
** preparing package for lazy loading
Warning: replacing previous import ‘hour’ when loading ‘lubridate’
Warning: replacing previous import ‘mday’ when loading ‘lubridate’
Warning: replacing previous import ‘month’ when loading ‘lubridate’
Warning: replacing previous import ‘wday’ when loading ‘lubridate’
Warning: replacing previous import ‘week’ when loading ‘lubridate'
Warning: replacing previous import ‘yday’ when loading ‘lubridate’
Warning: replacing previous import ‘year’ when loading ‘lubridate’
** help
* installing help indices
** building package indices ...
** testing if installed package can be loaded
Warning messages:
1: replacing previous import ‘hour’ when loading ‘lubridate’
2: replacing previous import ‘mday’ when loading ‘lubridate’
3: replacing previous import ‘month’ when loading ‘lubridate’
4: replacing previous import ‘wday’ when loading ‘lubridate’
5: replacing previous import ‘week’ when loading ‘lubridate’
6: replacing previous import ‘yday’ when loading ‘lubridate’
7: replacing previous import ‘year’ when loading ‘lubridate’
I'm really not sure what to make of those, but they seem like typical warnings from overwriting stuff in namespace. In any case, I am able to install the package, but here's what happens when I try to use it:
library(pkg)
Overriding + and - methods for POSIXt, Date and difftime
Warning messages:
1: replacing previous import ‘hour’ when loading ‘lubridate’
2: replacing previous import ‘mday’ when loading ‘lubridate’
3: replacing previous import ‘month’ when loading ‘lubridate’
4: replacing previous import ‘wday’ when loading ‘lubridate’
5: replacing previous import ‘week’ when loading ‘lubridate’
6: replacing previous import ‘yday’ when loading ‘lubridate’
7: replacing previous import ‘year’ when loading ‘lubridate’
d <- my.function(arg1, arg2)
Error in MATCH(x, x) : could not find function "MATCH"
Using traceback(), I found out that this is being generating during a call to merge.zoo(). So I tried loading zoo by hand during my R session and voila, then the function works correctly without the error message.
I have tried changing the ordering of the imports by hand in both the "pkg-package.R" file, as well as in NAMESPACE. Based on something I found elsewhere, I have not added any Imports or Depends to DESCRIPTION, however. Help?
Depends
in theDESCRIPTION
. – mathematical.coffee