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

Wrong means, medians #96

Open
oleksii-nikolaienko opened this issue Feb 2, 2023 · 4 comments
Open

Wrong means, medians #96

oleksii-nikolaienko opened this issue Feb 2, 2023 · 4 comments

Comments

@oleksii-nikolaienko
Copy link

Hi,
I get a very strange output for means, medians and max values in this example:

table1::table1(~ x | y, data.frame(x=c(2000:2009), y="Y"))

image

While the following works correctly:

table1::table1(~ x | y, data.frame(x=c(0:9), y="Y"))

image

It seems to have something to do with rounding when I try to use other ranges of x: c(10, 19), c(100, 109), c(1000, 1009).
I think the output is very wrong when it comes to years (as I have in the first example)

@benjaminrich
Copy link
Owner

benjaminrich commented Feb 2, 2023

Please have a look at #24.

There is nothing wrong with the calculations, just increase the number of significant digits to 5 (default is 3).

table1::table1(~ x | y, data.frame(x=c(2000:2009), y="Y"), digits=5)

(Aside: While it seems strange to me that you would want to take the the mean of calendar years, I guess you know what you are doing)

@oleksii-nikolaienko
Copy link
Author

Yes, sorry for that, I didn't know default value for digits=3. Can see it specified in signif_pad(), but not in table1().
On my issue: in this case I wanted to know median and min/max, and instead of 2005 [2001, 2009] got 2010 [2000, 2010]. And pasted it right into my manuscript without checking with summary(). So while I understand that there is no bug here, it is still a bit misleading, especially given the different default for number of digits... Made me think how many times I could make the same mistake before...

@oleksii-nikolaienko
Copy link
Author

I get your point on the default values, but some people get confused. Would it be possible to specifically explain this better in the table1() help page?

@benjaminrich
Copy link
Owner

Thanks. I will take in under consideration for the next release.

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