-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flatten the matrix slot? #29
Comments
I don't know, I think the benefits of keeping it outweigh the advantages of removal. responses in reverse order:
I don't feel too strongly about this though, just that it's worth considering the utility of the |
Good points. I see that the accessor functions could be helpful if we retain the nested structure of My biggest qualm pertains to the matF+matC functions (jonesor/Rage#19). What I meant was that having a E.g. In the tidy version of
In a version with
I just prefer the simplicity of the tidy version. More pedantically... I don't love the asymmetry of the single nested column in an otherwise tidy object. The accessor functions are nice, but they're slightly unintuitive for a user used to tidy data frames, particularly in an object where the 47 other variables can all be accessed with There's also asymmetry in that user-derived MPMs (e.g. collapsed, rearranged, λ-standardized) or MPM components will live outside A counterpoint to the convenience of only passing one |
…cessor functions for data, small updates to functions. Closes 4 issues. 1. Changed the structure of CompadreData object, so that now there are two slots: 1. 'data', which contains a data.frame with the original 'metadata' plus a list column 'mat' containing the CompadreM objects, and 2. a 'version' slot which contains version information. This addresses issues jonesor#27 and jonesor#29 at github.com/jonesor/Rcompadre and ties the order metadata and matrices more closely together. 2. Accessor functions for almost anything contained in the databases have been added, which addresses issue jonesor#23. It is still possible to access matrices and metadata separately to one another, even though they are now contained in one data.frame. 3. All functions and methods have been updated to use these accessor functions rather than accessing information directly from the slots (completes issue jonesor#15). If we wish to change the structure of the classes in the future, this minimises the work needed to go into making sure the methods and functions work with the new structure, as we only have to change the accessor functions rather than everything. Accessor functions should be used in the future rather than accessing information directly from the slots. 4. Added a pseudo superclass CompadreMorData which allows methods to be utilised by both classes (these pertain to matrices and matrixClass information). 5. Changed collapseMatrix, getMeanMatF, IdentifyReprodStages, rearrangeMatrix, splitMatrix so that they work with CompadreM objects as well as specific matrices that have been passed to them.
I've mostly come around on this. I personally prefer working with a totally flat structure, but I see the benefits of having a single |
(With apologies for the length)
Rather than the nested structure of the current
mat
slot (or "column", à la #27), I propose having separate list-columns formatA
,matU
,matF
,matC
,MatrixClassOrganized
, andMatrixClassAuthor
. The reason is that most MPM functions (e.g. inpopdemo
,popbio
) act on a matrix, so we should make it easier for users to access matrices, and particularly, to vectorize over a set of matrices.Vectorizing
Currently, vectorizing with
popdemo
orpopbio
functions requires writing a custom function to access the slots withinmat
, e.g.With a flat structure a user could vectorize over
matA
without having to write a custom function, e.g.The situation is more nuanced when it comes to
Rage
, becauseRage
functions could eventually work withCompadreM
objects, in which case a user could vectorize overdb@mat
without writing custom functions. However, for the Rage functions that take a single matrix (i.e.kEntropy
,qsdConverge
,reprodStages
,identfityReproStages
,splitMatrix
), vectorizing with the flat version would be just as easy, e.g.For some
Rage
functions that take multiple matrix arguments (e.g.matrixElementPerturbation
), vectorizing with theCompadreM
object would admittedly be nicer, e.g.For
Rage
functions that will often be used with additional row-specific arguments (e.g.longevity
,rearrangeMatrix
,reprodStages
), vectorizing with the flat version is just as easy, (e.g. calculating lifespan wrt the first non-propagule stage)Finally, there are a few
Rage
functions (R0
,dEntropy
,lifeTimeRepEvents
, andmakeLifeTable
) for which having aCompadreM
method would make the function overly difficult to document and understand (in my opinion), because the user may wish to apply them to matF-only, matC-only, or matF and matC (or in the extreme case ofmakeLifeTable
, also matU-only).As outlined in jonesor/Rage#19, I think we should simplify these functions so that they only take one 'reproductive matrix' argument (e.g.
matR
), and correspondingly make it easier for users to derive and storematFC
(=matF
+matC
) withindb
.Printing
The flat version makes it easier to examine a series of matrices from the same study (e.g. reflecting different years or populations)
Though the
CompadreM
version makes it easier to examine all the matrices for a given rowMatrix validation
I think the matrix-validation function of the
CompadreM
class could be moved to a new Rcompadre function (e.g.db_validate
). I don't see too much benefit of 'built-in' validation of things like matrix dimension, non-negative values, etc. Definitely those things should be validated on the COMPADRE side, but after that I think it's fine to leave things to the user.The text was updated successfully, but these errors were encountered: