EcoJulia / SpatialEcology.jl

Julia framework for spatial ecology - data types and utilities
Other
58 stars 7 forks source link

Add filter / naming functions? #24

Open kescobo opened 6 years ago

kescobo commented 6 years ago

I was thinking it would be nice to have some filter!-type functions, as well as the ability to rename fields. So for example, I'd like to be able to do:

cm = ComMatrix([1 1 3; 1 2 1; 3 4 2],
                ["feat1","feat2","feat3"],
                ["foo_test", "bar_test", "baz_test"]
                )
sitenames!(cm, ["foo", "bar", "baz"])

to change the cm.sitenames to ["foo", "bar", "baz"]. Basically equivalent to the names! function from dataframes. And something similar for specnames! to change row names.

The other thing that would be useful would be to have the ability to do something like:

~~filter!(cm, startswith.(sitenames(cm), "b"))~~

I'm less certain how to implement this, since it would be useful to filter along both rows and columns, but I think there should be precedents in other table-creating packages. Though maybe this will be solved with the indexing stuff mentioned in #22

Only other thing is whether renaming functions should go here, or in EcoBase (I think maybe the later?)

kescobo commented 6 years ago

I'm an idiot - I see now that the view function basically does what I'm asking for in filter. So ignore that part...

mkborregaard commented 6 years ago

Yes, view should be able to do that exactly. I like the sitenames! function, will implement.

kescobo commented 6 years ago

Should be fairly straightforward I think... though maybe best to implement in EcoBase as placenames! and thingnames!?