• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Format numbers in tbl_summary gtsummary r

Resolved: Format numbers in tbl_summary gtsummary r

0
By Isaac Tonny on 16/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

Problem:
I want to format big numbers in a categorical tbl_summary to simplify zeros.
Reprex:
Output:
Characteristic N = 40,000
variable1
Cat 10,000 (25%)
Dog 10,000 (25%)
Lion 10,000 (25%)
Tiger 10,000 (25%)

Desired output:
Characteristic N = 40
variable1 Results in thousands
Cat 10 (25%)
Dog 10 (25%)
Lion 10 (25%)
Tiger 10 (25%)

Attempts:
As you can see, is a frequency table but with the big numbers smplified by thousands. I was trying to achieve my desired output with functions inside gtsummary like style_number but i keep recieving the error: Error in .x * scale : non-numeric argument to binary operator. The answer could also be in the r package scales (function: label_number).
Let me know if you have some insights. Thanks.

Answer:

In the digits= argument you can pass both integers AND styling functions. In the example below, I wrote a new function that scales large numbers to the nearest thousand.
Example!
enter image description here Created on 2022-06-15 by the reprex package (v2.0.1)

If you have better answer, please add a comment about this, thank you!

gtsummary r
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: significance letter above bar graphic in wrong order

01/04/2023

Resolved: VBA – Applying border around the areas with value/text

01/04/2023

Resolved: How can I implement a function depending on picked up items?

01/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.