jverzani / gWidgets2

Rewrite of gWidgets
35 stars 9 forks source link

gfilter: head/tail/some(..., 1000) preset #29

Closed landroni closed 10 years ago

landroni commented 11 years ago

This is sitting rather high on my TODO list ( https://github.com/landroni/gWidgets2-filter/blob/master/TODO ), but I have trouble deciding how best to integrate it into gfilter().

I was thinking of providing a "preset" filtering item that could be 'Add'ed as other row filters, but instead of focusing on any given variable, it would present a generic interface for head(), tail() and car::some(). The funs are extremely useful when inspecting a data frame, for example when checking that some operation on a DF went as expected.

This thingy could take the form of a gfilterpreset() fun modeled on gfilter(), that when called via 'Add preset' would add a widget that has three radio choices c('head', 'tail', 'some'), with 'some' being disabled if package 'car' is not available and below either a scrollbar with 1:nrow(df) or a spinner with same range. I think it should be possible to checkbox negative for the range, as head and tail allow, but not some.

Is this feasible?

landroni commented 11 years ago

Oh, by default dffilter() would load this preset with head(..., 1000), as rstudio::View() does. I think it's useful, and if the user wants something else, they can remove the preset or change the subset value/function.

jverzani commented 11 years ago

I don't see why you couldn't do this. It might be better to parse some input for the lines, e,g,:

1:10, 11, 15:22

Since you are parsing, you could even have an end (julia like, with 1:end) instead of 1:length(x) (but x is not really a variable so that would be confusing).

landroni commented 10 years ago

I now came up with a working prototype of the feature. Several implementation issues persist:

landroni commented 10 years ago

All the issues noted above have been addressed one way or another in the updated PR. Now the feature is pretty much complete and ready for inclusion.