// globals

function preprocess () {
echo ('require(car)\n');
}


function printout () {
	doPrintout (true);
}

function preview () {
	preprocess ();
	calculate ();
	doPrintout (false);
}

function doPrintout (final) {
	vars = str_replace ("\n", ",", trim (getValue ("x"))) ;

echo ('data <- data.frame (' + vars + ')\n');
echo ('\n');
	if (final) { 
echo ('rk.header ("Scatterplot Matrix", parameters=list ("Diagonal Panels", "' + getValue("diag")) echo ('", "Plot points", "' + getValue ("plot_points") + '", "Smooth", "' + getValue ("smooth") + '", "Ellipses", "' + getValue ("ellipse") + ' at 0.5 and 0.9 levels."))\n');
echo ('\n');
echo ('rk.graph.on ()\n');
	} 
echo ('try (scatterplot.matrix(data, diagonal="' + getValue("diag")) echo ('", plot.points=' + getValue ("plot_points") + ', smooth=' + getValue ("smooth") + ', ellipse=' + getValue ("ellipse") + '))\n');
	if (final) { 
echo ('rk.graph.off ()\n');
	}
}

