Re: Data-dependent Reference line in GPL
Posted by Kirill Orlov on Oct 18, 2021; 2:09pm
URL: http://spssx-discussion.165.s1.nabble.com/Data-dependent-Reference-line-in-GPL-tp5740795p5740804.html
A solution found by Jon Peck (via SPSSX List emailing):.
Jon's comment: "This seems incredibly arcane, but it seems to give the right answer. Isn't GPL wonderful?"
GGRAPH
/GRAPHDATASET NAME="graphdataset" VARIABLES= X Y
/GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
SOURCE: s=userSource(id("graphdataset"))
DATA: X=col(source(s), name("X"))
DATA: Y=col(source(s), name("Y"))
GUIDE: axis(dim(1), label("X"))
GUIDE: axis(dim(2), label("Y"))
ELEMENT: point(position(X*Y))
ELEMENT: line(position(smooth.mean.uniform(X*Y)))
END GPL.
This solution is very concise thus wonderful, but seems less general than the "add data approach" shown above by Andy. In particularly, it is so far unclear (to me) if this solution can be adopted to produce a vertical reference line too. (Andy's remark:
"I prefer just adding data to the dataset, as you can see this becomes
a bit more verbose. But horses for courses. (I know Jon showed a way to use smooth.mean
to generate the horizontal line, but most of the time I want to generate vertical lines,
not sure how to do that using "summary." functions.")
------------------
So,
JON, ANDY - THANK YOU very much for your answers!
Bruce - thanks for the link, too.
It would be nice if SPSS improves its Reference line options in GPL - for example, to make it possible to use a summary function (returning a scalar value) right on the GUIDE: form.line(position(?, ?)) syntax statement.