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

inappropriate rounding messes up the plot, when data points are close to zero #21

Open
aminadibi opened this issue Jan 31, 2018 · 1 comment
Labels

Comments

@aminadibi
Copy link

For example, using the following dataset,

# A tibble: 14 x 3
   X__1            SE_withOPTIMAL `SE_without OPTIMAL`
 * <chr>                    <dbl>                <dbl>
 1 HR_male                 0.0340               0.0357
 2 HR_age                  0.0186               0.0211
 3 HR_nowmsk               0.0408               0.0450
 4 HR_oxygen               0.0457               0.0439
 5 HR_fev1pre              0.0416               0.0412
 6 HR_statin               0.0433               0.0413
 7 HR_azithromycin         0.0387               0.0359
 8 HR_LAMA                 0.0511               0.0456
 9 HR_LABA                 0.0480               0.0504
10 HR_ICS                  0.0507               0.0756
11 HR_sgrq                 0.0130               0.0132
12 HR_BMI10                0.0268               0.0290
13 HR_OPTIMAL              0.0512               0.307

will result in:
image

@leeper leeper added the bug label Apr 18, 2018
@ibecav
Copy link
Collaborator

ibecav commented Jul 5, 2018

@aminadibi I just recently added ggslopegraph2 to the package and it uses some different approaches to this problem. You're welcome to give it a try if you like. This should work for you and includes the data you provided in your example. Please note I'm also very curious as to whether your last datapoint is an error? The code will work either way but if that is an accurate value it is so far up the scale the other datapoints will be hard to read. For purposes of clarity I made it .0307 for now.

devtools::install_github("leeper/slopegraph")
library(slopegraph)
# A tibble: 14 x 3
aminadibi <- tibble::as.tibble(read.table(header = TRUE, 
text = "X__1            SE_withOPTIMAL SE_withoutOPTIMAL
HR_male                 0.0340               0.0357
HR_age                  0.0186               0.0211
HR_nowmsk               0.0408               0.0450
HR_oxygen               0.0457               0.0439
HR_fev1pre              0.0416               0.0412
HR_statin               0.0433               0.0413
HR_azithromycin         0.0387               0.0359
HR_LAMA                 0.0511               0.0456
HR_LABA                 0.0480               0.0504
HR_ICS                  0.0507               0.0756
HR_sgrq                 0.0130               0.0132
HR_BMI10                0.0268               0.0290
HR_OPTIMAL              0.0512               0.0307"))
#
newaminadibi <- reshape2::melt(aminadibi, id = "X__1", variable.name="SE", value.name = "SurvivalRate")
head(newaminadibi)
ggslopegraph2(newaminadibi, SE, SurvivalRate, X__1,
              title = "data points are close to zero #21",
              linecolor = "light gray",
              subtitle = "With defaults")
newaminadibi$rSurvivalRate <- signif(newaminadibi$SurvivalRate, 2)
ggslopegraph2(newaminadibi, SE, rSurvivalRate, X__1,
              title = "data points are close to zero #21",
              linecolor = "light gray",
              subtitle = "With signif = 2")

aaa1
aaa2

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

No branches or pull requests

3 participants