Created
October 20, 2020 02:23
-
-
Save daviddalpiaz/f3ce55689b52325cb080c0c54527d29d to your computer and use it in GitHub Desktop.
An example where the results differ by OS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
y = c(2637,2495,2977,3062,3203,3860,3856,2920,1970,2920,3090,3941,3042,2836, | |
1928,2977,4990,3983,3175,2240,3651,3544,2750,3416,3572,2353,2100,3132, | |
1729,3643,2782,3005,2424,3799,3175,2778,3941,2211,2084,2353,3062,3770, | |
3997,3374,4167,2414,2495,2920,2126,3487,2977,3572,1588,3614,3473,2523, | |
3997,2557,2821,3637,3232,3969,3756,3460,3790,3651,2055,2877,2466,3100, | |
2835,2906,3651,4238,3912,2084,2055,2410,2495,3225,2125,2733,3827,2948, | |
2466,3770,2922,2920,1021,2296,4593,2438,3090,3203,3402,2187,3651,1818, | |
1928,2600,1893,3317,1330,3062,3884,3080,3232,2442,2495,3884,2663,1899, | |
3331,1790,2977,2225,3062,3860,3104,3629,3203,2769,2410,2450,2665,2466, | |
1135,3225,3274,3317,4111,3234,3544,3444,3033,2187,2807,2296,3090,1928, | |
3430,3274,3459,1701,3317,2325,3303,2381,2948,2301,3062) | |
set.seed(2) | |
breaks = unique(quantile(y, probs = seq(0, 1, length = 5))) | |
z = cut(y, breaks, include.lowest = TRUE) | |
q = unique(as.character(z), nmax = NA) # this is the same | |
order(q) # this is different | |
table(z) # result matches across OSes | |
table(as.character(z)) # result differs on MacOS | |
# y = y / 1000 # using this results in same result across OSes | |
# alternatively, keeping the original scaling, but removing 3062 "works" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment