Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grouping comparer function #79

Open
renkun-ken opened this issue Oct 20, 2014 · 1 comment
Open

Grouping comparer function #79

renkun-ken opened this issue Oct 20, 2014 · 1 comment
Assignees

Comments

@renkun-ken
Copy link
Owner

list.group() uses identical() to group list elements by a field while list.class() uses contains(), i.e. match(x, table, nomatch = 0L) > 0L to classify list elements by a field.

The consequence is that list.group() is by default extremely strict. For example,

> library(rlist)
> x <- list(1,1,1L,1L)
> list.group(x, .)
$`1`
$`1`[[1]]
[1] 1

$`1`[[2]]
[1] 1


$`1`
$`1`[[1]]
[1] 1

$`1`[[2]]
[1] 1


> list.class(x, .)
$`1`
$`1`[[1]]
[1] 1

$`1`[[2]]
[1] 1

$`1`[[3]]
[1] 1

$`1`[[4]]
[1] 1

This output may be ambiguous and sometimes is undesired.

@renkun-ken renkun-ken self-assigned this Oct 20, 2014
@renkun-ken
Copy link
Owner Author

The groups are determined by unique() which differentiates 1 and 1L.

> unique(list(1,1L))
[[1]]
[1] 1

[[2]]
[1] 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant