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

suggestion add function that deals with excel currencies #129

Closed
marcoblume opened this issue Jul 28, 2017 · 3 comments
Closed

suggestion add function that deals with excel currencies #129

marcoblume opened this issue Jul 28, 2017 · 3 comments

Comments

@marcoblume
Copy link

Hi,

thank you for the package. clean_names() has been really helpful.

Would it be possible to add a function that deals with the currencies formats that exist in excel and correctly transforms the strings into numeric values?

As far as I can see these are the most currencies format that excel offers

$100.12
-$222.22
($222.22)
100.12 £
-222.22 £

Thanks in advance

@sfirke
Copy link
Owner

sfirke commented Aug 1, 2017

Hi Marco,

Thanks for the note and idea. Have you tried readr::parse_number()? It handles all of the above instances except that if you want the wrapping parentheses to indicate negative, you'd need to first replace a leading parenthesis with a negative sign using gsub or similar.

@marcoblume
Copy link
Author

marcoblume commented Aug 1, 2017

Hi,

thanks for the answer. I have been recommending your package to colleagues of mine who are not that familiar with R, who often read in Excel data. Your package has been a blessing for them as it helps them get started right away thanks to clean_names().
gsub is a little too daunting for them at this stage and as you said parse_number() does almost the entire job just falls short on the (222$) numbers but I'll write a function for them that will do that for them.

@sfirke
Copy link
Owner

sfirke commented Aug 3, 2017

Sounds good. Here's a lead for your function to handle the numbers in parentheses: https://stackoverflow.com/questions/5068705/processing-negative-number-in-accounting-format looks like lots of other folks have run into this so maybe you can adapt from another user's code or package.

@sfirke sfirke closed this as completed Aug 3, 2017
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

2 participants