Comments (12)
I tend to agree they do not bring enough value. From all those other variants, I only imagine the subset one brings value. For other instances simply wrapping the result in appropriate function like:
which(x %in{}% c("a", "b"))
seems to be enough.
Let's drop these which
all
and sum
?
from inops.
pinning and closing as I think we're good here!
from inops.
This to me seems like the most important issue to being with.
My suggestion would be to start implementing functionality that absolutely will be in the package. Maybe get one function in near-perfect shape (maybe some %in% variant). Then implement others according to that template (other %in% variants and %in%). And after that see if we can find natural expansions to branch out without deviating from the form/syntax.
If you like the names of %in{}% and %in[]%, etc - we can start with them maybe.
This is open to suggestions/comments of course.
from inops.
A first try to define the scope of this package :
It aims to provide infix operators that help detect, subset or replace elements of a vector or list.
output type
It means that ideally all functionalities should have 3 counterparts :
- detect : logical output, e.g.
%in%
,%in[]%
or`==`
(the former and latter not in the package)
It seems like we've decided to use the in
suffix for all detect functionalities.
- replace : in place replacement : e.g
%in%<-
,%in[]%<-
or ``==<-
.
For replacement not in place we can either use `%in[]<-%`(x, range, value)
or replace(x, x %in[]% range, value)
- subset : definitive names haven't been decided for those yet, but they would return a subset of the input,
could be :
%subset%
/%subset[]%
/%subset==%
(currently implemented)%{}in%
/%{}in[]%
/%{}==%
%{}%
/%{}[]%
/%{}==%
%intersection_all%
/%subset[]%
/%subset==%
(%intersection_all%
is likeintersection()
but keeps duplicates)/%vin%
/%vin[]%
/ ``%v==%
with `v` for value
(but better discuss them in naming thread)
action type
we have several collection of operators, with their variants to satisfy the 3 types of outputs :
- comparison
==
etc - range :
%in[]%
etc - sets :
%in%
etc - count (
%#in%
with naming conventions to define)
applied vs atomic
This description doesn't include currently named %in{}%
because I don't see actually how it fits yet, or if we should have another set of functions for applied operation
from inops.
I like the one sentence scope you provided. Thou I would add that they should work on a matrix (or an array) and preserve the dimensions. so that
data.matrix(iris[,-5]) %in[]% c(0,2)
would return a logical matrix, not a vector form like %in%
does. This is mainly a selfish need, because all the data I work with is always in a matrix format (not even data.frame...)
I agree with everything you wrote here, except I think I wasn't clear when explaining %in{}%
. I tried to expand on that in the "names" issue.
from inops.
great then let's make all these functions consstent with matrix lhs, what about data frames ?
could be :
- unsupported
- supported only if all items of compatible type
- just return FALSE everywhere for incompatible types
from inops.
I would vote for supporting data.frames if possible. Only drop this if it's hard to do.
from inops.
Took a look at what I was doing with infixer - and I think data.frame
should be supported. The main reason being that equality operators (>
, ==
, etc) support data.frame
.
from inops.
good point, and iris == 3
returns a matrix. I'll take the comparison operators as a reference for consistency. I'm not sure what i'll do with the assignment versions for these cases though but I'll play around with it and then we can discuss it further here.
I think I should be able to implement all the changes we discussed during the week
from inops.
Yup, seems like iris == 3
returns a matrix, not a data.frame. Maybe to be consistent our operators also should return a matrix in that case?
from inops.
yes I believe they should
from inops.
We agreed now that the scope is detect (logical output), subset, replace, matches according to equality, inequality, intersection with a range or regex, using a decently generalisable syntax to welcome additional operators if necessary.
These operators return the same type of data (or warning/errors) than equality and comparison operators do, when applied on flat atomic vectors, matrices, lists or data frames, with the difference that our right hand sides have different restrictions depending on the operator. They also treat NA
as equality and comparison operators do, i.e. they keep them (unlike %in%
).
Replacement operators are wrapper around our detection operators and replace
and are named as the assignment form of the detection operators ( e.g. %in{}%
and %in{}<-%
), and assignment forms to equality and comparison operators are defined as well. (==<-
etc)
Additional ideas are to design additional infix operators to wrap our detection operators in :
which()
to get numeric indicesall()
orany()
to get a logical scalarsum()
to get a count
But all those are considered out of scope for now as it's not clear if they bring enough value.
from inops.
Related Issues (20)
- First CRAN release HOT 85
- README HOT 8
- consistency between in_check ops and equality/comparison ops ? HOT 8
- simplify replace ops HOT 2
- package name HOT 7
- `%in%<-`, `%out%`, `%out%<-` HOT 1
- `%in{}%` on (lists of) language objects HOT 1
- regex ops don't have the same consistency to == as other ops HOT 1
- inconsistent way of dealing with factors in `%in{}%` HOT 3
- Improve error "NAs are not allowed in subscripted assignments" in replacement functions HOT 5
- Case for replacement acting as `ifelse()` ? HOT 4
- `%#in%` family HOT 18
- add example `NA %in{}% NA` HOT 5
- CRAN issues HOT 25
- dealing with NAs HOT 6
- conflicted doesn't like inops HOT 14
- The following object is masked from ‘package:base’: <<-
- More fame and glory HOT 1
- multiple replacements HOT 5
- Operator for selecting quantile range?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from inops.