Skip to content

[Request] names for tstrsplit results #1379

@franknarf1

Description

@franknarf1

On SO, I found myself doing...

trial = c("9-5", "7-5", "13-3", "17-6")
wdays = c("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
setDT(tstrsplit(trial, "-", type.convert=TRUE))[, 
  paste0(wdays[V2 + 1], " ", V1, ":00")
]

It would be nice if I could instead do

with( tstrsplit(trial, "-", type.convert=TRUE, list.names=TRUE), 
  paste0(wdays[V2 + 1], " ", V1, ":00")
)

so V1, V2, etc are the names in the result.

The list.names arg could be extended to specify other naming rules as well.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions