I have two strings that look the same but are not identical.
> t
[1] "2009_Manaus_Aerotáxi_crash"
> t2
[1] "2009_Manaus_Aerotáxi_crash"
> identical(t,t2)
[1] FALSE
> str(t)
chr "2009_Manaus_Aerotaxi_crash""| __truncated__
> str(t2)
chr "2009_Manaus_Aerotáxi_crash"
How can I force these two strings to be equal?
Thanks
If you write your data out to csv and then open the file in a program like Notepad++, then turn on view>all characters you will be able to see if there are something at the ends of your strings like LF or \r or \n. Then you will have a better idea what you need to remove and can use the above advice (stringi::str_cmp()) to test an example of a string that you know was not working to be sure you fixed it. For me the issue turned out to be spaces and this solved my problem:
own_dept_expect %>% mutate(check_field = stringr::str_replace_all(check_field,"[:space:]"," ")) %>% write_csv("C:/Users/me/Desktop/spaces_suck.csv")
I verified in Notepad++ that it was all uniform now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With