[Rd] incremental plots with pdf and dev.copy

2007-02-28 Thread Giampiero Salvi
Hi,
I am trying to produce incremental plots directly using the pdf
device. I mean that I want to produce a plot, save it in a pdf
file, then add details and save the new plot in a new file, and
so on. Before I used to do this with x11, by just adding graphics to
a plot and then using dev.copy2eps at the right times for each eps
figure. Now I want to do this in batch mode and the x11 device is not
available.

This is how I go about it:

pdf(file="file1.pdf")  # create the first plot
dev.control(displaylist='enable') # allow copying print devices
plot(1:10) # first plot
dev.copy(pdf,file="file2.pdf") # create the second plot
dev.control(displaylist='enable')
dev.off(dev.prev())# close the first plot
points(2,3)# add to the second plot
dev.copy(pdf,file="file3.pdf") # create the third plot
dev.off(dev.prev())# close the second plot
points(3,2)# add to the third plot
dev.off()

The problem is this works only for the first two plots. For the
third I get an error at "dev.copy(pdf,file="file3.pdf")"

Error in dev.copy(pdf, file = "file3.pdf") :
invalid graphics state

I also tried to remove the second dev.control statement, but in
that case the same error is delayed to the "points(3,2)" line
(plotting in the third plot).

Is this behaviour expected? Is there a better way to do what I'm
trying to do?

Thank you!
Giampiero

-- 

Giampiero Salvi, Ph.D.
www.speech.kth.se/~giampi  skype: giampierosalvi
Royal Institute of Technology, Speech, Music and Hearing
Lindstedtsv.24,SE-100 44,Stockholm,   Sweden
Tel: +46-8-790 62 93Fax: +46-8-790 78 54

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Tk GUI : Select Packages from CRAN Dialog does not have a scrollbar (PR#9534)

2007-02-28 Thread a . maier
Full_Name: Alois Maier
Version: 2.4.1 
OS: OpenSUSE 10.2 x86-32
Submission from: (NULL) (192.12.81.1)


How to reproduce the bug:
start R with --gui=tk option.
R --gui=tk

select from menu: Packages - Install Packages from CRAN.
The first dialog box that appears (CRAN mirror selection) has a scrollbar.
The following dialog box (package selection) shows no scrollbar. This makes it
difficult to select packages with names after "ade4". 

The dialog box also does not show title.

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] incremental plots with pdf and dev.copy

2007-02-28 Thread Hin-Tak Leung
This is an r-help question - please post to the relevant list next time.

The problem is with your "dev.off(dev.prev())" lines - you should
have used just "dev.off()" plain, without the dev.prev() inside.
As for why, please read the help pages.

Giampiero Salvi wrote:
> Hi,
> I am trying to produce incremental plots directly using the pdf
> device. I mean that I want to produce a plot, save it in a pdf
> file, then add details and save the new plot in a new file, and
> so on. Before I used to do this with x11, by just adding graphics to
> a plot and then using dev.copy2eps at the right times for each eps
> figure. Now I want to do this in batch mode and the x11 device is not
> available.
> 
> This is how I go about it:
> 
> pdf(file="file1.pdf")  # create the first plot
> dev.control(displaylist='enable') # allow copying print devices
> plot(1:10) # first plot
> dev.copy(pdf,file="file2.pdf") # create the second plot
> dev.control(displaylist='enable')
> dev.off(dev.prev())# close the first plot
> points(2,3)# add to the second plot
> dev.copy(pdf,file="file3.pdf") # create the third plot
> dev.off(dev.prev())# close the second plot
> points(3,2)# add to the third plot
> dev.off()
> 
> The problem is this works only for the first two plots. For the
> third I get an error at "dev.copy(pdf,file="file3.pdf")"
> 
> Error in dev.copy(pdf, file = "file3.pdf") :
> invalid graphics state
> 
> I also tried to remove the second dev.control statement, but in
> that case the same error is delayed to the "points(3,2)" line
> (plotting in the third plot).
> 
> Is this behaviour expected? Is there a better way to do what I'm
> trying to do?
> 
> Thank you!
> Giampiero
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Help with "row.names = as.integer(c(NA, 5))" in file from dput

2007-02-28 Thread Mike Prager
I am trying to understand why syntax used by dput() to write
rownames is valid (say, when read by dget()).  I ask this
because I desire to emulate its actions *reliably* in my For2R
routines, and I won't be comfortable until I understand what R
is doing.

Given data set "fred":

> fred
id  var1
1 1991 0.4388587
2 1992 0.8772471
3 1993 0.6230486
4 1994 0.2340929
5 1995 0.5005605

we can try this--

> dput(ats, control = "all")
structure(list(id = c(1991, 1992, 1993, 1994, 1995), var1 =
c(0.4388587, 0.8772471, 0.6230486, 0.2340929, 0.5005605)),
.Names = c("id", "var1"), row.names = as.integer(c(NA, 5)),
class = "data.frame")

In the above result, why is the following part valid?

row.names = as.integer(c(NA, 5))

given that the length of the RHS expression is 2, while the
needed length is 5.

Moreover, the following doesn't work:

> row.names(fred) <- as.integer(c(NA,5))
Error in `row.names<-.data.frame`(`*tmp*`, value = c(NA, 5)) : 
invalid 'row.names' length

Is there any reason why the expression

c(NA,5) 

is better here than the more natural

1:5 

here?

I will appreciate help from anyone with time to reply.

MHP

-- 
Mike Prager, NOAA, Beaufort, NC
* Opinions expressed are personal and not represented otherwise.
* Any use of tradenames does not constitute a NOAA endorsement.

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Help with "row.names = as.integer(c(NA, 5))" in file from dput

2007-02-28 Thread Peter Dalgaard
Mike Prager wrote:
> I am trying to understand why syntax used by dput() to write
> rownames is valid (say, when read by dget()).  I ask this
> because I desire to emulate its actions *reliably* in my For2R
> routines, and I won't be comfortable until I understand what R
> is doing.
>
> Given data set "fred":
>
>   
>> fred
>> 
> id  var1
> 1 1991 0.4388587
> 2 1992 0.8772471
> 3 1993 0.6230486
> 4 1994 0.2340929
> 5 1995 0.5005605
>
> we can try this--
>
>   
>> dput(ats, control = "all")
>> 
> structure(list(id = c(1991, 1992, 1993, 1994, 1995), var1 =
> c(0.4388587, 0.8772471, 0.6230486, 0.2340929, 0.5005605)),
> .Names = c("id", "var1"), row.names = as.integer(c(NA, 5)),
> class = "data.frame")
>
> In the above result, why is the following part valid?
>
> row.names = as.integer(c(NA, 5))
>
> given that the length of the RHS expression is 2, while the
> needed length is 5.
>
> Moreover, the following doesn't work:
>
>   
>> row.names(fred) <- as.integer(c(NA,5))
>> 
> Error in `row.names<-.data.frame`(`*tmp*`, value = c(NA, 5)) : 
> invalid 'row.names' length
>
> Is there any reason why the expression
>
> c(NA,5) 
>
> is better here than the more natural
>
> 1:5 
>
> here?
>
>   
It's mainly a space-saving device. Originally, row.names was a character 
vector, but storage of character vectors is quite inefficient, so we now 
allow integer names and also a very short form where 1:n is stored just 
using the single value n. To distinguish the latter two, we use the 
c(NA, n) form, because row names are not allowed to be missing.

Consider the following and notice how the string row names take up 
roughly 36 bytes per  record where the actual data are only 8 bytes per 
record.

 > d<-data.frame(x=rnorm(1000))
 > object.size(d)
[1] 8392
 > row.names(d)<-as.character(1:1000)
 > object.size(d)
[1] 44384
 > row.names(d)<-1000:1
 > object.size(d)
[1] 12384
 > row.names(d)<-NULL
 > object.size(d)
[1] 8392




> I will appreciate help from anyone with time to reply.
>
> MHP
>
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Help with "row.names = as.integer(c(NA, 5))" in file from dput

2007-02-28 Thread Mike Prager
Peter--

Thank you.  Am I correct in understanding, then, that,

(1) The syntax I asked about is a special case, and the parser
and/or dget() somehow recognize it as such, and

(2) The syntax 1:15 (where 15 is the number of rows)  should
work just as well as c(NA, 15)?

I ask, again, because I want to ensure the widest possible
compatibility for the way For2R is writing data in emulation of
dput().

--Mike


Peter Dalgaard <[EMAIL PROTECTED]> wrote:

> Mike Prager wrote:
> > I am trying to understand why syntax used by dput() to write
> > rownames is valid (say, when read by dget()).  I ask this
> > because I desire to emulate its actions *reliably* in my For2R
> > routines, and I won't be comfortable until I understand what R
> > is doing.
> >
> > Given data set "fred":
> >
> >   
> >> fred
> >> 
> > id  var1
> > 1 1991 0.4388587
> > 2 1992 0.8772471
> > 3 1993 0.6230486
> > 4 1994 0.2340929
> > 5 1995 0.5005605
> >
> > we can try this--
> >
> >   
> >> dput(ats, control = "all")
> >> 
> > structure(list(id = c(1991, 1992, 1993, 1994, 1995), var1 =
> > c(0.4388587, 0.8772471, 0.6230486, 0.2340929, 0.5005605)),
> > .Names = c("id", "var1"), row.names = as.integer(c(NA, 5)),
> > class = "data.frame")
> >
> > In the above result, why is the following part valid?
> >
> > row.names = as.integer(c(NA, 5))
> >
> > given that the length of the RHS expression is 2, while the
> > needed length is 5.
> >
> > Moreover, the following doesn't work:
> >
> >   
> >> row.names(fred) <- as.integer(c(NA,5))
> >> 
> > Error in `row.names<-.data.frame`(`*tmp*`, value = c(NA, 5)) : 
> > invalid 'row.names' length
> >
> > Is there any reason why the expression
> >
> > c(NA,5) 
> >
> > is better here than the more natural
> >
> > 1:5 
> >
> > here?
> >
> >   
> It's mainly a space-saving device. Originally, row.names was a character 
> vector, but storage of character vectors is quite inefficient, so we now 
> allow integer names and also a very short form where 1:n is stored just 
> using the single value n. To distinguish the latter two, we use the 
> c(NA, n) form, because row names are not allowed to be missing.
> 
> Consider the following and notice how the string row names take up 
> roughly 36 bytes per  record where the actual data are only 8 bytes per 
> record.
> 
>  > d<-data.frame(x=rnorm(1000))
>  > object.size(d)
> [1] 8392
>  > row.names(d)<-as.character(1:1000)
>  > object.size(d)
> [1] 44384
>  > row.names(d)<-1000:1
>  > object.size(d)
> [1] 12384
>  > row.names(d)<-NULL
>  > object.size(d)
> [1] 8392
> 
> 
> 
> 
> > I will appreciate help from anyone with time to reply.
> >
> > MHP
> >
> >
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Mike Prager, NOAA, Beaufort, NC
* Opinions expressed are personal and not represented otherwise.
* Any use of tradenames does not constitute a NOAA endorsement.

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Help with "row.names = as.integer(c(NA, 5))" in file from dput

2007-02-28 Thread Peter Dalgaard
Mike Prager wrote:
> Peter--
>
> Thank you.  Am I correct in understanding, then, that,
>
> (1) The syntax I asked about is a special case, and the parser
> and/or dget() somehow recognize it as such, and
>
> (2) The syntax 1:15 (where 15 is the number of rows)  should
> work just as well as c(NA, 15)?
>
> I ask, again, because I want to ensure the widest possible
> compatibility for the way For2R is writing data in emulation of
> dput().
>
>   
Essentially yes, but

(1) it is not as much about syntax, but about internal representation

(2) Yes, it gives the same result -- the 1:15 is recognized as a vector 
that can be optimized to c(NA, 15). Needing to have the code check for 
this case is of course somewhat wasteful.

To wit:

 > dd <- structure(list(x = c(1.19894055844457, -0.476584995973736, 
1.90525643132169,   -0.726616166810353, 0.590506316214127)), .Names = 
"x", row.names =1:5, class = "data.frame") -
 > dput(dd,control="all")
structure(list(x = c(1.19894055844457, -0.476584995973736, 
1.90525643132169,
-0.726616166810353, 0.590506316214127)), .Names = "x", row.names = 
as.integer(c(NA,
5)), class = "data.frame")


> --Mike
>
>
> Peter Dalgaard <[EMAIL PROTECTED]> wrote:
>
>   
>> Mike Prager wrote:
>> 
>>> I am trying to understand why syntax used by dput() to write
>>> rownames is valid (say, when read by dget()).  I ask this
>>> because I desire to emulate its actions *reliably* in my For2R
>>> routines, and I won't be comfortable until I understand what R
>>> is doing.
>>>
>>> Given data set "fred":
>>>
>>>   
>>>   
 fred
 
 
>>> id  var1
>>> 1 1991 0.4388587
>>> 2 1992 0.8772471
>>> 3 1993 0.6230486
>>> 4 1994 0.2340929
>>> 5 1995 0.5005605
>>>
>>> we can try this--
>>>
>>>   
>>>   
 dput(ats, control = "all")
 
 
>>> structure(list(id = c(1991, 1992, 1993, 1994, 1995), var1 =
>>> c(0.4388587, 0.8772471, 0.6230486, 0.2340929, 0.5005605)),
>>> .Names = c("id", "var1"), row.names = as.integer(c(NA, 5)),
>>> class = "data.frame")
>>>
>>> In the above result, why is the following part valid?
>>>
>>> row.names = as.integer(c(NA, 5))
>>>
>>> given that the length of the RHS expression is 2, while the
>>> needed length is 5.
>>>
>>> Moreover, the following doesn't work:
>>>
>>>   
>>>   
 row.names(fred) <- as.integer(c(NA,5))
 
 
>>> Error in `row.names<-.data.frame`(`*tmp*`, value = c(NA, 5)) : 
>>> invalid 'row.names' length
>>>
>>> Is there any reason why the expression
>>>
>>> c(NA,5) 
>>>
>>> is better here than the more natural
>>>
>>> 1:5 
>>>
>>> here?
>>>
>>>   
>>>   
>> It's mainly a space-saving device. Originally, row.names was a character 
>> vector, but storage of character vectors is quite inefficient, so we now 
>> allow integer names and also a very short form where 1:n is stored just 
>> using the single value n. To distinguish the latter two, we use the 
>> c(NA, n) form, because row names are not allowed to be missing.
>>
>> Consider the following and notice how the string row names take up 
>> roughly 36 bytes per  record where the actual data are only 8 bytes per 
>> record.
>>
>>  > d<-data.frame(x=rnorm(1000))
>>  > object.size(d)
>> [1] 8392
>>  > row.names(d)<-as.character(1:1000)
>>  > object.size(d)
>> [1] 44384
>>  > row.names(d)<-1000:1
>>  > object.size(d)
>> [1] 12384
>>  > row.names(d)<-NULL
>>  > object.size(d)
>> [1] 8392
>>
>>
>>
>>
>> 
>>> I will appreciate help from anyone with time to reply.
>>>
>>> MHP
>>>
>>>
>>>   
>> __
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>> 
>
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] typo in reshape.Rd

2007-02-28 Thread Stephen D. Weigand
The 3 lines below are from paragraph 4 of \details in reshape.Rd.
In line [2], a space is needed before "where" and the "to" at the
end of the line should be removed.

[1]these names.  The default is variable names like \code{x.1},
[2]\code{x.2},where \code{split=list(regexp="\\.",include=FALSE)} to
[3]specifies to split at the dot and drop it from the name. To have 
alphabetic

Thanks,

Stephen


Stephen Weigand
Rochester, Minnesota, USA

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel