[Rd] R CMD check does not recognize S4 functions inside other functions?
Henric (Nilsson) Winell
nilsson.henric at gmail.com
Fri Aug 28 15:18:57 CEST 2009
On 2009-08-28 09:58, Martin Maechler wrote:
>>>>>> "GH" == Giles Hooker <gjh27 at cornell.edu>
>>>>>> on Thu, 27 Aug 2009 21:12:48 -0400 writes:
>
> GH> I am developing a new R package and am now checking it for submission to
> GH> CRAN.
>
> GH> The some functions in the package make use of the sparse matrix routines
> GH> in the package 'Matrix'.
>
> GH> When these are loaded in R, they create no problems.
>
> GH> However, when running R CMD check, I run into the following error in
> GH> executing the examples in a .rd file:
>
> >> DD = Matrix(diag(1,200),sparse=TRUE)
> >> tDD = t(DD)
>
> {{well, the transpose of a diagonal matrix, really ??}}
>
> Just a remark: For larger values of n=200,
> it would be more efficient (and elegant) to directly use
>
> DD <- Diagonal(200)
>
> See ?Diagonal, and e.g.,
>
> > Diagonal(4)
> 4 x 4 diagonal matrix of class "ddiMatrix"
> [,1] [,2] [,3] [,4]
> [1,] 1 . . .
> [2,] . 1 . .
> [3,] . . 1 .
> [4,] . . . 1
> > .symDiagonal(4)
> 4 x 4 sparse Matrix of class "dsCMatrix"
>
> [1,] 1 . . .
> [2,] . 1 . .
> [3,] . . 1 .
> [4,] . . . 1
>
>
>
>
>
> >>
> >> fres = FitMatchOpt(coefs=coefs,which=2,pars=pars,proc)
> GH> Error in t.default(DD) : argument is not a matrix
> GH> Calls: FitMatchOpt -> t -> t.default
> GH> Execution halted
>
> GH> The first two lines of the function FitMatchOpt are
>
> GH> DD = Matrix(diag(1,200),sparse=TRUE)
> GH> tDD = t(DD)
>
> GH> These were fine when given in the examples section of the .rd file
> GH> directly. However, when defined within a function in the package, the
> GH> lines cause an error.
>
> How does your package "get Matrix"?
>
> I'm sure there's some problem in requiring Matrix, in either
> your DESCRIPTION or your NAMESPACE (or a .First.library or ...)
>
> Your DESCRIPTION should have
>
> Depends: ...., Matrix
> Imports: ...., Matrix
Can you please clarify the simultaneous use of `Depends:' and `Imports'.
The Writing R Extensions manual explicitly says that:
"Packages declared in the 'Depends' field should not also be in the
'Imports' field."
Thanks,
Henric
>
> and your NAMESPACE
>
> either
> importFrom("Matrix", .....)# the things you need
>
> or (if you use many things from the Matrix package, and/or
> in some way just *extend* it ...)
>
> import("Matrix")
>
>
>
> Does that help?
>
> Best regards,
> Martin Maechler
>
>
> GH> Sparse matrices improve the computational efficiency of the routines I
> GH> am developing and I would like to use them. But I'm not sure how I can
> GH> get around this error.
>
> GH> Many thanks,
>
> GH> Giles Hooker
>
> GH> ______________________________________________
> GH> R-devel at r-project.org mailing list
> GH> https://stat.ethz.ch/mailman/listinfo/r-devel
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
More information about the R-devel
mailing list