Comments (8)
Also what would be the expected output for list(list(1,2)) %in{}% list(list(1,2), 3)
?
I believe we should unlist by default the rhs, it seems to be what range()
does anyway :
range(list(1,list(3,4)))
#> [1] 1 4
Then I think failing like ==
does is good enough so we avoid opening a new can of worms and can aim to have everything consistent with ==
rather than %in%
, does that sound right ?
list(list(1,2)) %in% list(list(1,2), 3)
#> [1] TRUE
list(list(1,2)) == list(list(1,2), 3)
#> Error in list(list(1, 2)) == list(list(1, 2), 3): comparaison de ces types non implémentée
list(1,2) %in% list(1, 3)
#> [1] TRUE FALSE
list(1,2) == list(1, 3)
#> Error in list(1, 2) == list(1, 3): comparaison de ces types non implémentée
c(1,2) == list(1, 3)
#> [1] TRUE FALSE
c(1,2) %in% list(1, 3)
#> [1] TRUE FALSE
list(1,2) == c(1, 3)
#> [1] TRUE FALSE
list(1,2) %in% c(1, 3)
#> [1] TRUE FALSE
Created on 2019-08-18 by the reprex package (v0.3.0)
from inops.
I've pushed a few changes, including making %in{}%
consistent, other check ops were ok, and I made tests for those
from inops.
Making it consistent with ==
sounds about right to me!.
Also I am wondering if there is a way to make them adhere to "group generics". Specifically "Group Ops" in ?groupGeneric
from inops.
Group "Ops":
... (arithmetic ops)
"==", "!=", "<", "<=", ">=", ">"
... (on unary ops)
The classes of both arguments are considered in dispatching any member of this group. For each argument its vector of classes is examined to see if there is a matching specific (preferred) or Ops method. If a method is found for just one argument or the same method is found for both, it is used. If different methods are found, there is a warning about ‘incompatible methods’: in that case or if no method is found for either argument the internal method is used.
I think group generics allow identical(iris < 3, 3 > iris)
to be TRUE
, I think it would be confusing in our case, you would want "^foo" %in~% x
to work as x %in~% "^foo"
? Or maybe I'm missing something.
Note that the data.frame methods for the comparison ("Compare": ==, <, ...) and logic ("Logic": & | and !) operators return a logical matrix instead of a data frame, for convenience and back compatibility.
This is implemented in our operators already
If the members of this group are called as functions, any argument names are removed to ensure that positional matching is always used.
we could do that, but I don't see the point, the positional matching is used by primitives for speed as far as I understand, and operators are almost never invoked as functions.
from inops.
What I meant is that if somebody writes a custom S3 (or S4 for that matter) object and implements Ops.class <- function(e1, e2) { ... }
that it would extend automatically to the operators in this package as well.
Maybe it doesn't make much sense, since the e2
in our case is not an object of a new class.
Yeah let's drop this. Bad idea.
from inops.
regex ops must be made consistent as well + tests and then we can close this
from inops.
regex ops defined and should behave ok, tests to design still
from inops.
closing this as we have an issue about unit tests
#7
from inops.
Related Issues (20)
- First CRAN release HOT 85
- README 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.