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

Vectorise functions #6

Open
ms130 opened this issue Sep 21, 2020 · 1 comment
Open

Vectorise functions #6

ms130 opened this issue Sep 21, 2020 · 1 comment

Comments

@ms130
Copy link
Contributor

ms130 commented Sep 21, 2020

The functions in this repository would be more useful if they were able to act on a vector, rather than only on a single value. For example, if you wanted to use the format_perc.R function to change fractions to percentages for an entire column, ready for insertion into a publication table.

@stanley-rudkin-moj
Copy link
Contributor

I am stumbling into problems with this now as well. To vectorise them, do we just need to add sapply like this?

format_perc <- function(fraction, error_on_NA = TRUE) {formatted_percentages <- sapply(fraction, function(x) {...}) return(formatted_percentages)}

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

No branches or pull requests

2 participants