how to obtain "par(ask=TRUE)" with trellis-plots

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

how to obtain "par(ask=TRUE)" with trellis-plots

Leo Gürtler
Dear alltogether,

how can a delay like possible with par(ask=TRUE) be attained while using
trellis-plots within a loop or something like that?
the following draws each plot without waiting for a signal
(mouse-klick), so par() does not work for that:

library(nlme)
for(i in 1:3)
{
  fitlme <- lme(Orthodont)
  par(ask=TRUE)                     # does not work with trellis....
  print( plot(augPred(fitlme)) )
}

thanks,

leo

--

email: [hidden email]
www: http://www.anicca-vijja.de/

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

gregexpr() - length of the matched text to a vector

Petri Palmu


Hi,

I'm using gregexpr(). As a result something like this:

# starting positions of the match:
[[1]]
[1] 7 18

# length of the matched text:
attr(,"match.length")
[1] 4 4

Now, I'd like to have a matrix,
  7    4
18   4

but I don't know how to handle the attr(,"match.length") ...?
The format of the output is pretty unclear to me in that respect.

Thanks in advance,
Petri
----------------------
Petri Palmu, M.Soc.Sc
Statistician
[hidden email]

Geneos Ltd
tel:+358 9 4366 2512
gsm: +35840 55 249 55
fax:+ 358 9 4366 2523
P.O. Box 25 (Tukholmankatu 2)
FIN-00251, Helsinki, Finland

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: gregexpr() - length of the matched text to a vector

Petri Palmu
Now I found a solution that seems to work OK for me:
attributes(gregexpr(expression, text)[[1]])

Petri

At 15:00 11.1.2006 +0100, Petri Palmu wrote:


>Hi,
>
>I'm using gregexpr(). As a result something like this:
>
># starting positions of the match:
>[[1]]
>[1] 7 18
>
># length of the matched text:
>attr(,"match.length")
>[1] 4 4
>
>Now, I'd like to have a matrix,
>   7    4
>18   4
>
>but I don't know how to handle the attr(,"match.length") ...?
>The format of the output is pretty unclear to me in that respect.
>
>Thanks in advance,
>Petri
>----------------------
>Petri Palmu, M.Soc.Sc
>Statistician
>[hidden email]
>
>Geneos Ltd
>tel:+358 9 4366 2512
>gsm: +35840 55 249 55
>fax:+ 358 9 4366 2523
>P.O. Box 25 (Tukholmankatu 2)
>FIN-00251, Helsinki, Finland
>
>______________________________________________
>[hidden email] mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


----------------------
Petri Palmu, M.Soc.Sc
Statistician
[hidden email]

Geneos Ltd
tel:+358 9 4366 2512
gsm: +35840 55 249 55
fax:+ 358 9 4366 2523
P.O. Box 25 (Tukholmankatu 2)
FIN-00251, Helsinki, Finland

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: gregexpr() - length of the matched text to a vector

Ben Bolker
In reply to this post by Petri Palmu
Petri Palmu <petri.palmu <at> geneos.fi> writes:


> I'm using gregexpr(). As a result something like this:
>
> # starting positions of the match:
> [[1]]
> [1] 7 18
>
> # length of the matched text:
> attr(,"match.length")
> [1] 4 4
>
> Now, I'd like to have a matrix,
>   7    4
> 18   4
>


  something like
 x1 = gregexpr("iss",c("mississippi"))
 x2 = rbind(x1[[1]],attr(x1[[1]],"match.length"))
 x2
     [,1] [,2]
[1,]    2    5
[2,]    3    3

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: gregexpr() - length of the matched text to a vector

Seth Falcon-2
In reply to this post by Petri Palmu
Hi Petri,

On 11 Jan 2006, [hidden email] wrote:

> I'm using gregexpr(). As a result something like this:
>
> # starting positions of the match:
> [[1]]
> [1] 7 18
>
> # length of the matched text:
> attr(,"match.length")
> [1] 4 4
>
> Now, I'd like to have a matrix,
> 7    4
> 18   4
>
> but I don't know how to handle the attr(,"match.length") ...?
> The format of the output is pretty unclear to me in that respect.

Brief description of the format: a list.  Each element of the list
is a result that corresponds to a string element in the input
character vector.  Each element consists of an integer vector of
starting positions for a match.  The integer vector has a match.length
atttribute consisting of an integer vector of match lengths.

Whew.  Would a matrix be better?  Probably.

To get a list of matrices you can do:

> txt
[1] "foobarfoobazfoofoo" "foo"                "bar"              
[4] "foofoofoo"        
> lapply(gregexpr("foo", txt), function(x) cbind(x, attr(x, "match.length")))
[[1]]
      x  
[1,]  1 3
[2,]  7 3
[3,] 13 3
[4,] 16 3

[[2]]
     x  
[1,] 1 3

[[3]]
      x  
[1,] -1 -1

[[4]]
     x  
[1,] 1 3
[2,] 4 3
[3,] 7 3


HTH,

+ seth

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: how to obtain "par(ask=TRUE)" with trellis-plots

Deepayan Sarkar
In reply to this post by Leo Gürtler
On 1/11/06, Leo Gürtler <[hidden email]> wrote:

> Dear alltogether,
>
> how can a delay like possible with par(ask=TRUE) be attained while using
> trellis-plots within a loop or something like that?
> the following draws each plot without waiting for a signal
> (mouse-klick), so par() does not work for that:
>
> library(nlme)
> for(i in 1:3)
> {
>   fitlme <- lme(Orthodont)
>   par(ask=TRUE)                     # does not work with trellis....
>   print( plot(augPred(fitlme)) )
> }

See ?grid.prompt in the grid package. To use it you can either attach
grid, or do

grid::grid.prompt(TRUE)

Deepayan
--
http://www.stat.wisc.edu/~deepayan/

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: how to obtain "par(ask=TRUE)" with trellis-plots

Peter Dalgaard
Deepayan Sarkar <[hidden email]> writes:

> On 1/11/06, Leo Gürtler <[hidden email]> wrote:
> > Dear alltogether,
> >
> > how can a delay like possible with par(ask=TRUE) be attained while using
> > trellis-plots within a loop or something like that?
> > the following draws each plot without waiting for a signal
> > (mouse-klick), so par() does not work for that:
> >
> > library(nlme)
> > for(i in 1:3)
> > {
> >   fitlme <- lme(Orthodont)
> >   par(ask=TRUE)                     # does not work with trellis....
> >   print( plot(augPred(fitlme)) )
> > }
>
> See ?grid.prompt in the grid package. To use it you can either attach
> grid, or do
>
> grid::grid.prompt(TRUE)

I happened to need this today (some example() sections are a bit
unhelpful without it) and the only way I figured it out was by recalling
this recent thread. Any chance of putting a suitable pointer in the
help pages for trellis.par.set and/or trellis.device?

--
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - ([hidden email])                  FAX: (+45) 35327907

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: how to obtain "par(ask=TRUE)" with trellis-plots

Deepayan Sarkar
On 14 Jan 2006 11:17:18 +0100, Peter Dalgaard <[hidden email]> wrote:
> Deepayan Sarkar <[hidden email]> writes:

[...]

> > See ?grid.prompt in the grid package. To use it you can either attach
> > grid, or do
> >
> > grid::grid.prompt(TRUE)
>
> I happened to need this today (some example() sections are a bit
> unhelpful without it) and the only way I figured it out was by recalling
> this recent thread. Any chance of putting a suitable pointer in the
> help pages for trellis.par.set and/or trellis.device?

Will do.

Deepayan

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html