R-helpers: I am experiencing some odd behavior with the 'matrix' function that I have not experienced before and was wondering if there is something that I was missing in my code.
--------------------------------- > sessionInfo() R version 2.6.1 (2007-11-26) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] splines grid stats graphics grDevices utils datasets methods [9] base other attached packages: [1] meta_0.8-2 car_1.2-7 arm_1.1-1 R2WinBUGS_2.1-6 [5] coda_0.13-1 lme4_0.99875-9 Matrix_0.999375-3 nlme_3.1-86 [9] latticeExtra_0.3-1 RColorBrewer_1.0-2 survival_2.34 MASS_7.2-39 [13] foreign_0.8-23 RGraphics_1.0-6 lattice_0.17-4 loaded via a namespace (and not attached): [1] rcompgen_0.1-17 tools_2.6.1 > rm(list=ls()) > matrix(c(7,47,4,38,20,96,1,14,10,48,2,101,12,161, # Make a data matrix + 1,28,1,19,22,49,25,162,31,200,9,39,22,193, + 0.5,45.5,31,131,4,75,31,220,7,55,3,91,14.5, + 25.5,3,65,25,54,24,41,37,95,11,17,26,49,13, + 84,38,170,29,60,9,20,44,47,30,160,40,185,10, + 41,40,185,4.5,46.5,60,140,12,75,42,225,26,57, + 17,92,23.5,23.5,6,68), ncol=2, byrow=T) [,1] [,2] [1,] 7.0 47 [2,] 4.0 38 [3,] 20.0 96 [4,] 1.0 14 [5,] 10.0 48 [6,] 2.0 101 [7,] 12.0 161 [8,] 1.0 28 [9,] 1.0 19 [10,] 22.0 49 [11,] 25.0 162 [12,] 31.0 200 [13,] 9.0 39 [14,] 22.0 193 [15,] 0.5 46 [16,] 31.0 131 [17,] 4.0 75 [18,] 31.0 220 [19,] 7.0 55 [20,] 3.0 91 [21,] 14.5 26 [22,] 3.0 65 [23,] 25.0 54 [24,] 24.0 41 [25,] 37.0 95 [26,] 11.0 17 [27,] 26.0 49 [28,] 13.0 84 [29,] 38.0 170 [30,] 29.0 60 [31,] 9.0 20 [32,] 44.0 47 [33,] 30.0 160 [34,] 40.0 185 [35,] 10.0 41 [36,] 40.0 185 [37,] 4.5 46 [38,] 60.0 140 [39,] 12.0 75 [40,] 42.0 225 [41,] 26.0 57 [42,] 17.0 92 [43,] 23.5 24 [44,] 6.0 68 ------------------------------------ Note the problems in rows 15, 21, 37 and 43. They should read [0.5, 45.5], [14.5, 21.5], etc... The matrix function seems to be rounding the second column up to the next integer. Why would this occur? Can I do something to prevent this? I would very much appreciate any comments. Thanks, Brant Inman Mayo Clinic [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.