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

get_one_to_one() errors with duplicated dttm #543

Closed
olivroy opened this issue May 26, 2023 · 4 comments · Fixed by #544
Closed

get_one_to_one() errors with duplicated dttm #543

olivroy opened this issue May 26, 2023 · 4 comments · Fixed by #544

Comments

@olivroy
Copy link
Contributor

olivroy commented May 26, 2023

library(fs)
janitor::get_one_to_one(fs::dir_info())

Please briefly describe your problem and what output you expect.

fs::dir_info() |> janitor::get_one_to_one()
#> Error in `levels<-`(`*tmp*`, value = as.character(levels)):   factor level [5] is duplicated

Created on 2023-05-26 with reprex v2.0.2

This only seems to occur with duplicated dates, in this case with columns at position 5, 16, 17.

@olivroy olivroy changed the title get_one_to_one() errors with dttm get_one_to_one() errors with duplicated dttm May 26, 2023
@billdenney
Copy link
Collaborator

Thanks for reporting this. It does appear to be an error in the code, but I can't reproduce it because I don't have your fs::dir_info() output. Can you please make a minimal reproducible example where the input data is part of the reprex?

@olivroy
Copy link
Contributor Author

olivroy commented May 26, 2023

Hi, here is a the reproducible example (with dput)

dates <- structure(list(modification_time = structure(c(1684261364.85967, 
                                               1684274880.48328, 1684261364.85967, 1684418379.74664, 1685105253.21695, 
                                               1684418379.76668, 1684279133.50118, 1684161951.81434, 1684281651.93175, 
                                               1678483898.72893, 1685103626.03424), class = c("POSIXct", "POSIXt"
                                               )), access_time = structure(c(1685040222.34459, 1685041485.59089, 
                                                                             1685105067.68569, 1685040222.51569, 1685105253.21795, 1685105067.73877, 
                                                                             1685105253.66953, 1685106417.48391, 1685105253.66853, 1685041485.59089, 
                                                                             1685103652.82275), class = c("POSIXct", "POSIXt")), change_time = structure(c(1684261364.85967, 
                                                                                                                                                           1684274880.48328, 1684261364.85967, 1684418379.74664, 1685105253.21695, 
                                                                                                                                                           1684418379.76668, 1684279133.50118, 1684161951.81434, 1684281651.93175, 
                                                                                                                                                           1678483898.72893, 1685103626.03424), class = c("POSIXct", "POSIXt"
                                                                                                                                                           ))), row.names = c(NA, -11L), class = c("tbl_df", "tbl", "data.frame"
                                                                                                                                                           )) 
janitor::get_one_to_one(dates)
Error in `levels<-`(`*tmp*`, value = as.character(levels)) : 
  factor level [5] is duplicated

@billdenney
Copy link
Collaborator

The underlying issue is unusual here. What is happening is that the times with 5 decimal place precision differ but when converted by factor, they lose that precision and become the same.

billdenney added a commit that referenced this issue May 26, 2023
sfirke pushed a commit that referenced this issue Jun 2, 2023
…e identical factor levels (#544)

`get_one_to_one()` no longer errors with near-equal values that become identical factor levels (fix #543)
@sfirke
Copy link
Owner

sfirke commented Jun 2, 2023

thanks for reporting this @olivroy and for fixing @billdenney !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants