[R] cut - suggestion
BXC (Bendix Carstensen)
bxc at novonordisk.com
Fri Oct 26 13:14:59 CEST 2001
I often use cut in order to produce quick tabulations of continuous data.
But if you choose "sensibe cotpoints as in:
> z <- rnorm(100)
> table( cut( z, breaks=seq(-1,1,0.5) ),
+ cut( z, breaks=c(-100,0,100) ) )
(-100,0] (0,100]
(-1,-0.5] 18 0
(-0.5,0] 19 0
(0,0.5] 0 17
(0.5,1] 0 19
you get labels that do not align properly.
Looking into cut this descends from the definition of the labels:
ch.br <- formatC(breaks, dig = dig, wid = 1)
i.e. really from the default of the format-agrument of formatC, which
is "g" (significant digits). Inside formatC is namely:
if (missing(format) || is.null(format))
format <- if (mode == "integer")
"d"
else "g"
Significant digtits do not align properly and makes things difficult to
read,
so i sugget that a `,format="f"' be added in the definition of ch.br in
cut.
----------------------
Bendix Carstensen
Senior Statistician
Steno Diabetes Centre
Niels Steensens Vej 2
DK-2820 Gentofte
Denmark
tel: +45 44 43 87 38
mob: +45 28 25 87 38
fax: +45 44 43 73 13
bxc at novonordisk.com
www.biostat.ku.dk/~bxc
----------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list