Skip to content

implicit type promotion in fcoalesce and fifelse #4101

@BenoitLondon

Description

@BenoitLondon

Not sure I understand how the fcoalesce function is meant to be used but I found it not very user-friendly.

e.g I have a data.table coming from some computation or database and if one column is full of NA it will be of type Logical and then cant be used directly inside fcoalesce.

> fcoalesce(NA, 1L, 1.0)
Error in fcoalesce(NA, 1L, 1) : 
  Item 2 is type integer but the first item is type logical. Please coerce before coalescing.
> fifelse(TRUE, NA, 1.0)
Error in fifelse(TRUE, NA, 1) : 
  'yes' is of type logical but 'no' is of type double. Please make sure that both arguments have the same type.

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