From mpiktas at gmail.com  Fri Jan 13 14:09:36 2006
From: mpiktas at gmail.com (Vaidotas Zemlys)
Date: Fri, 13 Jan 2006 15:09:36 +0200
Subject: [Rd] Saving a plot in R-LINUX
In-Reply-To: <17350.64562.286742.136147@basebud.nulle.part>
References: <9707EBA615A57747A0668CECD4638A3009BBA8@mail.agso.gov.au>
	<17350.64562.286742.136147@basebud.nulle.part>
Message-ID: <e47808320601130509mad192b8ye540b35cad0d4b88@mail.gmail.com>

On 1/13/06, Dirk Eddelbuettel <edd at debian.org> wrote:
>
> On 13 January 2006 at 11:02, Augusto.Sanabria at ga.gov.au wrote:
> | Is there any way to save a plot produced by
> | R in a LINUX (Debian) machine?
>
> It is the same on every platform and ...
>
> | The window opened by R to put the plot in,
> | does not give any option to save it (there
> | are options to move, close, minimise it, etc.
> | but not to save it). How do you do that?
>

What about using dev.copy? Or am I missing something? In windows there
is a context menu when you click with the right mouse button, which
lets you choose how do you want to save the plot. On linux I came up
with such function, which albeit not perfectly but does the job:

d2b <- function(file="Rplot%d.bmp",height=4,width=4,res=150,which=dev.cur(),...)
{
    if(which!=dev.cur()) {
        cur <- dev.cur()
        dev.set(which)
    }
    else cur <- NULL

    dev.copy(device=bitmap,file=file,height=height,width=width,point=8,res=res,...)
    dev.off()
    if(!is.null(cur))dev.set(cur)
    else dev.set(which)
}

It copies told device (current by default) to bitmap file. This
function could be easily adapted for copying to other formats.

Since the answer was too easy, probably I did not understand question
correctly. In that case please ignore this message.

Vaidotas Zemlys
--
Doctorate student, http://www.mif.vu.lt/katedros/eka/katedra/zemlys.php
Vilnius University



[Rd] Saving a plot in R-LINUX
Vaidotas Zemlys