镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

New symbol to count rows matched in X[Y] #2124

Open

Description

@franknarf1

I was expecting these to give the same result:

X = data.table(id = "a", key = "id")
X["b", .N]              
# 1
X["b", .N, by=.EACHI][, sum(N)] 
# 0

Thinking it through, I understand why they don't, but it would be nice to have a simple way of getting a count of matches without always having to type .N, nomatch=0 (or nomatch=NULL after that the planned change, #857).

So maybe X[Y, .NMATCH], a special symbol that like by=.EACHI is only available in a join?

My use case is a table of (item, task) pairs, where my workflow involves skipping chunks of code iff I have no items associated with a task. So I parse that table like do_thistask = X["thistask", .N > 0L] but now realize I need nomatch=0/NULL.

Activity

  1. changed the title [-][Request] New symbol to count rows matched in X[Y][/-] [+]New symbol to count rows matched in X[Y][/+] on Apr 6, 2020
  2. added
    joinsUse label:"non-equi joins" for rolling, overlapping, and non-equi joins
    on Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    joinsUse label:"non-equi joins" for rolling, overlapping, and non-equi joins

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions