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

Consistent accuracy for number display #6

Closed
hope-data-science opened this issue Jan 31, 2023 · 1 comment
Closed

Consistent accuracy for number display #6

hope-data-science opened this issue Jan 31, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@hope-data-science
Copy link

hope-data-science commented Jan 31, 2023

I have seen the following plot in README, and I wonder whether we can keep a consistent accuracy, which means the "1" should be "1.00", and "1.4" should be "1.40" (I myself use scales package and yields similar results, and in many cases this should be adjusted). Thanks.
image

@jpquast
Copy link
Owner

jpquast commented Nov 9, 2023

@hope-data-science I agree with you. I found the issue in the paste() function. Didn't know it had this behaviour (see below). I fixed it now and it will be correct in the new version.

# Load library
library(ggplate)
#> 📊 Welcome to ggplate version 0.0.1! 📈
#>                             
#> 🖍 Have fun plotting your data! 💻

# Load data
data("data_continuous_96")

# Numeric values
data_continuous_96$Value
#>  [1] 1.19 0.88 0.17 0.85 0.78 0.23 1.95 0.40 0.88 0.26 1.47 3.04 0.05 0.97 0.90
#> [16] 0.02 2.06 1.01 0.92 1.66 0.12 0.41 1.70 0.24 0.26 2.12 0.17 0.83 0.75 0.25
#> [31] 0.62 0.28 1.36 0.18 0.04 0.03 1.71 0.41 0.35 1.24 1.82 1.17 0.33 0.51 0.23
#> [46] 0.41 0.33 2.73 1.00 0.47 0.05 0.17 0.08 0.67 1.40 0.35 1.05 0.62 1.82 0.10
#> [61] 0.50 0.07 0.20 0.67 0.63 1.65 0.64 0.38 0.87 1.68 1.41 0.98 0.36 0.50 0.65
#> [76] 0.03 1.51 0.37 0.11 0.10 0.39 0.07 0.84 0.41 1.13 0.83 1.11 0.19 0.64 0.32
#> [91] 0.51 1.64 0.85 0.32 1.12 0.91

# Problem when converted to character
paste0(data_continuous_96$Value)
#>  [1] "1.19" "0.88" "0.17" "0.85" "0.78" "0.23" "1.95" "0.4"  "0.88" "0.26"
#> [11] "1.47" "3.04" "0.05" "0.97" "0.9"  "0.02" "2.06" "1.01" "0.92" "1.66"
#> [21] "0.12" "0.41" "1.7"  "0.24" "0.26" "2.12" "0.17" "0.83" "0.75" "0.25"
#> [31] "0.62" "0.28" "1.36" "0.18" "0.04" "0.03" "1.71" "0.41" "0.35" "1.24"
#> [41] "1.82" "1.17" "0.33" "0.51" "0.23" "0.41" "0.33" "2.73" "1"    "0.47"
#> [51] "0.05" "0.17" "0.08" "0.67" "1.4"  "0.35" "1.05" "0.62" "1.82" "0.1" 
#> [61] "0.5"  "0.07" "0.2"  "0.67" "0.63" "1.65" "0.64" "0.38" "0.87" "1.68"
#> [71] "1.41" "0.98" "0.36" "0.5"  "0.65" "0.03" "1.51" "0.37" "0.11" "0.1" 
#> [81] "0.39" "0.07" "0.84" "0.41" "1.13" "0.83" "1.11" "0.19" "0.64" "0.32"
#> [91] "0.51" "1.64" "0.85" "0.32" "1.12" "0.91"

# Corrected output
paste0(format(data_continuous_96$Value, drop0Trailing = F))
#>  [1] "1.19" "0.88" "0.17" "0.85" "0.78" "0.23" "1.95" "0.40" "0.88" "0.26"
#> [11] "1.47" "3.04" "0.05" "0.97" "0.90" "0.02" "2.06" "1.01" "0.92" "1.66"
#> [21] "0.12" "0.41" "1.70" "0.24" "0.26" "2.12" "0.17" "0.83" "0.75" "0.25"
#> [31] "0.62" "0.28" "1.36" "0.18" "0.04" "0.03" "1.71" "0.41" "0.35" "1.24"
#> [41] "1.82" "1.17" "0.33" "0.51" "0.23" "0.41" "0.33" "2.73" "1.00" "0.47"
#> [51] "0.05" "0.17" "0.08" "0.67" "1.40" "0.35" "1.05" "0.62" "1.82" "0.10"
#> [61] "0.50" "0.07" "0.20" "0.67" "0.63" "1.65" "0.64" "0.38" "0.87" "1.68"
#> [71] "1.41" "0.98" "0.36" "0.50" "0.65" "0.03" "1.51" "0.37" "0.11" "0.10"
#> [81] "0.39" "0.07" "0.84" "0.41" "1.13" "0.83" "1.11" "0.19" "0.64" "0.32"
#> [91] "0.51" "1.64" "0.85" "0.32" "1.12" "0.91"

Created on 2023-11-09 with reprex v2.0.2

@jpquast jpquast added the bug Something isn't working label Nov 9, 2023
@jpquast jpquast self-assigned this Nov 9, 2023
@jpquast jpquast closed this as completed Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants