FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Don't warn about coercing j to integer · Issue #6594 · Rdatatable/data.table · GitHub

Don't warn about coercing j to integer #6594

Description

warning(_("Coerced j from numeric to integer. Please pass integer for efficiency; e.g., 2L rather than 2"));

I find this warning a bit annoying. It's very common in R to have double "just work" as integer. Why this of all places is there an efficiency concern?

I can't imagine the efficiency concern is real anyway -- unless we are coercing 1e7+ column numbers to integer I can't imagine there's a real performance implication.

I also see two cases where this might come up:

  1. You are passing j as a variable to set():

    setDT(DT, , col_idx, val)

    In this case, the recommendation is to do as.integer(col_idx), which is what assign.c is doing implicitly. Is there really any difference in efficiency?

  2. You are doing interactive work (as I just was when I came across this) and lazily omitting the L:

    setDT(DT, , c(1, 4), NULL)

    OK, I could write 1L/4L, and in package/production code, I probably should. But to throw a warning seems a bit heavy-handed. Users really under such use cases should be using lintr::implicit_integer_linter() to catch such cases.

Originally added a long time ago: e2cf7e2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL