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

Strings composed of only numbers are not compared as expected #370

Open
collinschwantes opened this issue Jul 17, 2024 · 0 comments
Open

Comments

@collinschwantes
Copy link

Whats the issue
Strings composed of only numbers are converted to numeric types

Use case
I have a set of GPS points stored as character that are required to have a certain level of precision. In some instances, lat/long values will end with 1 or more zeros. When data were entered, the trailing zeros were sometimes omitted and need to be updated. (e.g. data entered as 1 instead of 1.0000). I use a corrections log to update the data (changing 1 to 1.0000) and then use the comparedf function to make sure all changes have been made. However, when evaluating the difference between the original and the updated data, "1" and "1.0000" are treated as the same. So when I check if the expected number of changes were made the output from comparedf provides an undercount.

Reproducible example

old_df <- data.frame(a = as.character(1:10))

new_df <- old_df |> 
  dplyr::mutate(a = sprintf("%.*f",6,as.numeric(a)))
               
 arsenal::comparedf(new_df,old_df)
@collinschwantes collinschwantes changed the title Strings composed of only numbers are converted to numeric types Strings composed of only numbers are not compared as expected Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant