Skip to content

Make fwf_positions() guess end argument from start #996

@rcragun

Description

@rcragun

I would expect fwf_positions() to guess the value of end based on the value of start. If end is not specified, the best guess should be that end is lead(start)-1. Perhaps I misunderstand what arg=NULL means, but having end=NULL implies to me that end is optional. I believe that this function could be improved with some simple changes:

fwf_positions <- function (start, end, col_names = NULL) {
  if(missing(end)){
    end <- lead(start)-1L
  }
  col_names <- fwf_col_names(col_names, length(start))
  tibble(begin = start - 1L, end = end, col_names = col_names)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions