2
function preprocess () {
5
function calculate () {
9
$breaks = getRK_val ("breaks");
10
$scale = getRK_val ("scale");
2
function preprocess () {
5
function calculate () {
15
doPrintout (false); // only this one actually needed...
18
// internal helper functions
19
function doPrintout ($final) {
20
$densityscaled = getRK_val ("densityscaled");
21
$bw = getRK_val ("bw");
22
$adjust = getRK_val ("adjust");
23
$narm = getRK_val ("narm");
24
$n = getRK_val ("n"); //calls "resolution"
11
25
$x = getRK_val ("x");
12
if ($breaks == "int") {
13
$breaksopt = "breaks=seq (as.integer (min (" . $x . "))-0.5, as.integer (max (" . $x ."))+0.5)";
15
} else if (!empty ($breaks)) {
16
$breaksopt = "breaks=\"" . $breaks . "\"";
19
rk.header ("Histogram", list ("Frequency", "<? echo $scale; ?>", "Breaks algorithm", <? echo ("\"" . $breaks . "\""); ?>, "Variable", rk.get.description (<? echo ($x); ?>)))
26
$plot_adds = getRK_val ("plotoptions.code.calculate");
30
rk.header ("Histogram", list ("Variable", rk.get.description (<? echo ($x); ?>) <? if (($densityscaled) && getRK_val ("density")) { ?>, "Density bandwidth", "<? echo ($bw); ?>", "Density adjust", <? echo ($adjust); ?>, "Density resolution", <? echo ($n); ?>, "Density Remove missing values", <? echo ($narm); ?> <? } ?> <? getRK ("histogram_opt.code.preprocess"); ?>))
21
hist (<? echo ($x); ?>, <? echo ($breaksopt); ?>, freq = <? echo $scale; ?><? getRK ("plotoptions.code.printout"); ?>)
36
hist (<? echo ($x); getRK ("histogram_opt.code.calculate"); getRK ("histogram_opt.code.printout"); getRK ("plotoptions.code.printout"); ?>)
37
<? if (($densityscaled) && getRK_val ("density")) { ?>
38
lines(density(<? echo ($x); ?>, bw="<? echo ($bw); ?>", adjust = <? echo ($adjust); ?>, <? echo ($narm); ?>, n = <? getRK ("n"); ?>)<? getRK ("col_density.code.printout"); ?>)
40
<? if (!empty ($plot_adds)) { ?>
42
<? // print the grid() related code
43
printIndented ("\t", $plot_adds);