Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When guess_formats() is given a vector of length greater than 1, return a matrix #1171

Open
guslipkin opened this issue Nov 2, 2024 · 0 comments
Labels
feature a feature request or enhancement

Comments

@guslipkin
Copy link

guslipkin commented Nov 2, 2024

When lubridate::guess_formats() is given a vector of length greater than 1, it returns a vector that has had some form of vector recycling performed. This is less than useful because there is no easy way to associate a given input with a given output. However, the print_matches argument causes a very nice matrix to print out where each row corresponds with an item in the input vector and each column with a value in the orders argument. However, because the matrix is printed, there is no easy way to capture it. When x is a vector of length greater than one, that matrix should be returned and not the vector.

# the current behavior
lubridate::guess_formats(
  x = c('12-10-2024', '13-10-2024'), 
  orders = c('mdY', 'dmY'),
)
#>        OmdY        dOmY        dOmY         mdY         dmY         dmY 
#> "%Om-%d-%Y" "%d-%Om-%Y" "%d-%Om-%Y"  "%m-%d-%Y"  "%d-%m-%Y"  "%d-%m-%Y"
# the proposed behavior
lubridate::guess_formats(
  x = c('12-10-2024', '13-10-2024'), 
  orders = c('mdY', 'dmY')
)
#>      x            OmdY        dOmY        mdY        dmY       
#> [1,] "12-10-2024" "%Om-%d-%Y" "%d-%Om-%Y" "%m-%d-%Y" "%d-%m-%Y"
#> [2,] "13-10-2024" ""          "%d-%Om-%Y" ""         "%d-%m-%Y"

Created on 2024-11-01 with reprex v2.1.1

@guslipkin guslipkin changed the title When lubridate::guess_formats() is given a vector of length greater than 1, return a matrix When guess_formats() is given a vector of length greater than 1, return a matrix Nov 2, 2024
@vspinu vspinu added the feature a feature request or enhancement label Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants