forestgeo / fgeo.tool

[R-package on CRAN] General purpose tools for ForestGEO Packages
https://forestgeo.github.io/fgeo.tool
Other
2 stars 6 forks source link

New sync() #132

Closed maurolepore closed 5 years ago

maurolepore commented 5 years ago

This commit adds pick() which is the basis for sync() -- a general function to apply a function to one key dataframe in a list and propagate the indices to all other elements.

coveralls commented 5 years ago

Pull Request Test Coverage Report for Build 596


Totals Coverage Status
Change from base Build 595: 0.8%
Covered Lines: 618
Relevant Lines: 709

💛 - Coveralls
maurolepore commented 5 years ago

Ideas:

data /
  sync(key = NULL) /
  filter() /
  arrange(1) /
  unsync()

Code within sync() has the sync class with special behaviour. Whatever happens on rows is applyed to the key -- if not null -- then propagated to the other elements of the list. Maybe it understands only the main 5-dplyr-verbs.

Another way

data /
  sync(exression)

For example

data /
  sync(filter(this_column == "this_value"), key = "this_column")

or

data /
  sync(this_key_col, filter)(this_col == "this_value")
maurolepore commented 5 years ago

Relates, is the {rtbl} project.

Also consider a map_on() and map_off():

data /
  nest() /
  map_on(data) /
  filter(this_col == "this_value") /
  map_off()
  unnest()