Closed cynthiahqy closed 1 year ago
This is being implemented in xmap
:
More example code: https://github.com/tidyverts/tsibble/blob/main/R/as-tsibble.R
From Advanced R, 13.3 Classes
When using a class in a package, I recommend including the package name in the class name. That ensures you won’t accidentally clash with a class defined by another package.
But I don't like the look of xmap_xmap
, it feels tedious. xmap_df
probably makes more sense, because it indicates that it is a data.frame.
weights
should be numeric (<int>
or more likely <dbl>
)This one is fairly straight forward, if all links have weight 1 <int>
will suffice, otherwise <dbl>
is necessary and brings some floating point issues with it (see #30 also)
*_node
columns should maybe be factor columns?From R for Data Science:
In R, factors are used to work with categorical variables, variables that have a fixed and known set of possible values. They are also useful when you want to display character vectors in a non-alphabetical order.
Both the source and target nomenclature form a fixed and known set of possible node labels.
Possible downstream benefits:
xmap
xmap
completely covers a dataset (avoid need to compute unique(src_node)
)But could it cause issues when implementing transformation of data using an xmap
?
dplyr::join()
treat factor columns as character ones anyway?xmap
should accept integer and character vectors (since you can use numbers or letters or a mixture to encode classification categories)Probably want to retain whatever vector class the user provides for the from
and to
columns. Factor and character vectors make the most sense, but you could have integer codes. This is probably not a great idea, but there isn't any obvious reason xmap
should prohibit users from doing this.
graph_df
) are retainedxmap
(for conform::concord
checks)this has been migrated to #57
There are a few types of checks that need to happen when forming a valid xmap
:
xmap
Some of the data.frame attribute checks currently in validate_xmap()
are somewhat redundant because they are checked for in new_xmap()
. For example:
from
, weight
cols are actually present in the dfare all checked when forming the xmap_df
.
This means that the error messages in validate_xmap()
will never be triggered (since the function takes in an object of class xmap_df
.) However, it would still be useful to keep the more verbose error messages currently in validate_xmap()
to help users. Maybe I can move these into the as_xmap()
helper function?
More of a later thing, but parking ideas here.
print.xmap()
Existing methods:
{pillar}
by adding the tbl
class. This would make xmap a subclass of tibbles.{igraph}
style print: src_node -- weights --> target_node
The properties of a crossmap that might be useful to display:
plot.xmap()
plot.data.frame()
method does a scatterplot, which doesn't really make sense for a graphRead and Write methods #62 :
xmap_df
format (.csv)xmap_graph
format (.xml? or other?)Discussions have all moved to other issues -- mostly #57, #60 and #62
lots of internal functions currently assume inputs are valid panel maps. It would probably be sensible to implement some safeguards -- i.e. using classes
This could be (quickly) checked for using a class condition. Requires implementing a constructor/validation/helper function design pattern as described in 13.3 Classes, Advanced R -- see skeleton here:
27e9ff1/R/panel_map.R
Maybe this lives in a separate panelmap package though?