Plotting to SPSS viewer from R

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Plotting to SPSS viewer from R

Garry Gelade

Hi Jon

 

Thanks for your reply.

 

 

BEGIN PROGRAM R.

library(aplpack)

library(rpart)

mydata <- spssdata.GetDataFromSPSS()

subset <- mydata[, 3:4]

bagplot(subset,factor=2,show.baghull=TRUE, show.loophull=TRUE,

            show.whiskers=TRUE, show.looppoints= TRUE, precision=1,dkmethod=2,xlab= "x (yds)",

            axes=FALSE, ann=FALSE)

title("Bagplot")

axis(2, las=1, at=10*0:75)

axis(1, las=2, at=10*0:115)

END PROGRAM.

 

I’m not using any image format, I’m just using R to output to the sposs viewer. The result is as expected, except its square.  The bagplot function takes additional graphics parameters if required, and if I add a parameter such as asp=0.5 say, everything gets squashed including text.  I know this hapens with the regular plot() function too (this is an R feature, not an spss one!).

 

I know I can print from R to a png and change the height and width that way, but I was wondering if it was possible to control the print to the viewer eg. By setting the device or something.

I’m not aware of spssRGraphics – maybe that’s the solution. Any thoughts welcome.

 

Garry,

What image format are you using and what graphics package?  Can you send a small code example?  I tried inserting a jpg  using
spssRGraphics, and it came into the Viewer at the correct aspect ratio of the image.

You can, of course, drag the image borders in the Viewer to change the aspect ratio, but since those are image files, quality deteriorates if you change a graphic by a lot.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        Garry Gelade <[hidden email]>
To:        [hidden email],
Date:        01/31/2013 04:49 AM
Subject:        [SPSSX-L] Plotting to SPSS viewer from R
Sent by:        "SPSSX(r) Discussion" <[hidden email]>





Dear List,

I am using the R programming interface (BEGIN PROGRAM R) to produce plots in the SPSS viewer.  The default aspect ratio is square, but I want a rectangular plot.  If I use the asp (aspect ratio) parameter in the R plot() command, the whole thing looks squashed up.

Does anyone know how to set the height and width of the plot so it appears correctly in the SPSS viewer?

Thanks

Garry