generic functions
can we make a generic function dccm, and rename the current dccm to dccm.xyz ?
`dccm` <-
function(x, ...) {
if(inherits(x, "matrix")) {
class(x) <- c("matrix", "xyz")
UseMethod("dccm", x)
}
else
UseMethod("dccm")
}
Same also for mktrj.pca and mktrj.nma so that we can call mktrj( nma ) and mktrj( pca ) ?
Comments (10)
-
-
reporter beats me.. how about this non-elegant work around:
`dccm` <- function(x, ...) { if(inherits(x, "matrix")) { class(x) <- c("matrix", "xyz") UseMethod("dccm", x) } else if(inherits(x, "array")) { class(x) <- c("matrix", "mean") UseMethod("dccm", x) } else UseMethod("dccm") }
-
Might do job nicely, lets try it...
-
reporter hmm.. how should we make these s3 functions?
I have in dccm.Rd
\name{dccm} \alias{dccm} \title{ DCCM: Dynamical Cross-Correlation Matrix } \description{ Determine the cross-correlations of atomic displacements. } \usage{ dccm(x, ...) }
and e.g. in dccm.xyz.Rd:
\name{dccm.xyz} \alias{dccm.xyz} \title{ DCCM: Dynamical Cross-Correlation Matrix } \description{ Determine the cross-correlations of atomic displacements. } \usage{ \method{dccm}{xyz}(x, reference = apply(xyz, 2, mean), grpby=NULL, ncore=1, nseg.scale=1, ...) }
so that xyz has been renamed to x, and \dots are added :-P
any preference?
-
This looks good Lars. Having these consistent in terms of input argument names and of course all documented together in one dccm.Rd file (with an \alias{} entry for dccm.xyz() and dccm.nma()) is a good way to go I think.
So currently, if we have a input x from nma() it will have class="nma" and we will be good with calling dccm.nma(). A similar think could happen with output from nma.pdbs(). However, if we have a regular numeric matrix from fit.xyz() or similar that does not have a class="xyz" then do we need to define some dccm.default() that just calls dccm.xyz()? Or should we just rename dccm.xyz() to dccm.default()?
Perhaps this is not even an issue...
-
reporter All in one .Rd file, like this? I was afraid that would be a bit messy..?
\name{dccm} \alias{dccm} \alias{dccm.xyz} \alias{dccm.nma} \title{ DCCM: Dynamical Cross-Correlation Matrix } \description{ Determine the cross-correlations of atomic displacements. } \usage{ dccm(x, ...) \method{dccm}{xyz}(x, reference = apply(xyz, 2, mean), grpby=NULL, ncore=1, nseg.scale=1, ...) \method{dccm}{nma}(x, ...) }
-
Perhaps it is messy - I thought it would be more organized. Is it messy because of the long list of \arguments{}. The start would look just like you have it and
\arguments{ \item{x}{ a numeric matrix of Cartesian coordinates with a row per structure/frame, which will br passed to \code{dccm.xyz()}. Alternatively, an object of class \code{nma} as obtained from function \code{nma} that will be passed to the \code{dccm.nma()} function, see below for examples. } .... }
What do you think?
-
reporter hmm.. not sure. I committed a suggestion now. I tried to put it into one Rd file, but reversed it because of the diverse arguments and examples. its not only dccm.xyz and dccm.nma, but also dccm.enma, and dccm.mean ? check it out and see how you like it
-
I like it this way and can see its much clearer. Only improvement would be to add some more pointers to the individual functions within the "Details" section for dccm.Rd. This could have links similar to the "see also"section - which is missing plot.dccm(). Just with a sentence for what each one does.
btw: I have plot.dccm2() on my list of things to improve...
-
reporter - changed status to resolved
- Log in to comment
Great idea, I like it! - but, what should we call our tentative new dccm.mean() function then...