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

Number of decimals in process_map() #28

Open
bjornafugglas opened this issue Jul 3, 2020 · 2 comments
Open

Number of decimals in process_map() #28

bjornafugglas opened this issue Jul 3, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@bjornafugglas
Copy link

Hi!

Thank you for a fantastic package!

I am just getting started with bupaR so still have a lot to learn, but I can't find if it possible to change the number of decimals in the numbers showing in the process map created by process_map()? Or at least set number of decimals equal for the entire process map.

See example:

patients %>% process_map(
type_nodes = frequency("absolute_case"),
sec_nodes = frequency("relative_case"),
type_edges = frequency("relative_case"),
sec_edges = performance(median, "mins")
)

image

For my use case I would like to show all information rounded to 0 decimals, currently it is mixed between 1 and 2 decimals as you can see in the image.

@fmannhardt
Copy link
Member

I think as of now this is not configureable, but you could try to override the built-in functions processmapR::performance and processmapR::frequency. Have a look here at the sources:
https://github.com/bupaverse/processmapR/blob/master/R/performance.R

In theory you should be able to simply copy that code and change the way the label and tooltips gets formatted here:

tooltip = paste0(ACTIVITY_CLASSIFIER_, "\n", round(label, 2), " ",attr(type, "units_label")),

@fmannhardt fmannhardt added the enhancement New feature or request label Jul 3, 2020
@gertjanssenswillen
Copy link
Member

Small addition: for performance;: as you can specify any aggregation function, this can be done without changes. You just have to define a "rounded mean" function,, for example

your_function <- function(x) { round(mean(x), 0) }
process_map(log, performance(your_function))

However, this is not possible for frequency values, as in the example. For this a change of the code would be needed indeed. Probably an argument in the frequency() functio to configure this would be the way to go.

(Side note: the fact that it is mixed has to do with the second decimal being zero, would be my guess.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants