Re: [R] splom, plotmath: how to add three lines of information with alignment?

2011-04-20 Thread Marius Hofert
Dear Baptiste, 

many thanks, that worked :-)

For the alignment, I made a new minimal example and posted it under the subject 
"grid.table + splom: how to nicely align panel entries". 

Cheers,

Marius

On 2011-04-20, at 10:22 , baptiste auguie wrote:

> On 20 April 2011 19:23, Marius Hofert  wrote:
>> Dear Baptiste,
>> 
>> thank you for your help. I tried to built in your suggestions into the splom.
>> Below is the result. I decided to create the plotmath-expressions outside the
>> function splom2, this will allow me later to horizontally shift (via phantom,
>> for example) the table entries so that they will be vertically aligned 
>> according
>> to the "=" signs. Although an array is allowed to contain expressions, I 
>> could
>> not manage to create it properly. Do you know a solution?
>> 
>> Cheers,
>> 
>> Marius
>> 
>> library(lattice)
>> library(grid)
>> library(gridExtra)
>> 
>> ## splom with customized lower.panel
>> ## x: data
>> ## expr.arr: array of expressions [(i,j,) entry contains expressions which 
>> are
>> ##   plotted in a grid table in the lower panel (i,j)]
>> splom2 <- function(x, expr.arr){
>>## function for creating table
>>table.fun <- function(vec){ # single values for one panel
>>grid.table(vec,
>>   parse=TRUE, # parse labels as expressions
>>   theme=theme.list(
>>   gpar.corefill=gpar(fill=NA, col=NA), # make bg transparent
>>   core.just="left") # justification of labels
>>   )
>>}
>>## splom
>>splom(x, varname.cex=1.4,
>>  superpanel=function(z, ...){
>>  panel.pairs(z, upper.panel=panel.splom, 
>> lower.panel=function(i,j){
>>  table.fun(expr.arr[i,j,])
>>  }, ...)
>>  })
>> }
>> 
>> ## create data and array of expressions
>> d <- 4
>> x <- matrix(runif(d*1000), ncol=d)
>> expr.arr <- array(, dim=c(d,d,3), dimnames=c("i","j","val")) # d x d x 3 
>> elements
>> for(i in 1:d){
>>for(j in 1:d){
>># expr.arr[i,j,] <- expression(italic(a)==0, italic(bbb)==0, 
>> italic(c)==0) # does no work
>>expr.arr[i,j,] <- c(bquote(italic(a)==.(0)), 
>> bquote(italic(bbb)==.(0)), bquote(italic(c)==.(0))) # same here
>>}
>> }
>> 
>> ## plot
>> splom2(x, expr.arr)
>> 
> 
> Initializing your array with a list seems to work for whatever reason
> that's well above my head,
> 
> expr.arr <- array(list(NA,NA,NA), dim=c(d,d,3), dimnames=c("i","j","val"))
> 
> As for the alignment, there should be a better way using multiple
> columns in grid.table, but parse is struggling to interpret the = sign
> on its own. Again, I'm not sure why, this is deep magic to me.
> 
> 
> library(gridExtra)
> d = matrix(c("italic(a)==phantom('')", round(pi,4),
>  "italic(b)==phantom()", round(pi,6)), ncol=2, byrow=T)
> 
> grid.table(d, parse=T,theme=theme.list(
>  gpar.corefill=gpar(fill=NA, col=NA),
>  core.just="left", padding.h = unit(0, "mm") ))
> 
> HTH,
> 
> baptiste
> 
>> 
>> On 2011-04-20, at 01:33 , baptiste auguie wrote:
>> 
>>> Hi,
>>> 
>>> You may want to wait advice from someone who actually understands (the
>>> labyrinth that is) lattice's help for splom, but the following might
>>> be a start. I didn't understand what values you actually wanted
>>> displayed in the lower triangle panels, so I made up some random ones
>>> in a 3x3 matrix of 3-vectors.
>>> 
>>> library(lattice)
>>> library(gridExtra)
>>> 
>>> info <- function(x){
>>>  grid.table(c(bquote(italic(a)==.(x[1])),
>>>   bquote(italic(b)==.(x[2])),
>>>   bquote(italic(c)==.(x[3]))),
>>> core.just="left",
>>> parse=TRUE)
>>> }
>>> 
>>> U <- matrix(runif(3000), ncol=3)
>>> 
>>> splom(U,
>>> superpanel=function(z, ...){
>>>   ## dummy 3x3 matrix of 3 values to diplay
>>>   values <- replicate(9, round(rnorm(3), 3), simplify=FALSE)
>>>   dummy <- matrix(values, ncol=3, byrow=F)
>>>   panel.pairs(z, upper.panel=panel.splom,
>>>   lower.panel=function(i, j, ...){
>>> print(paste(i,j)) # current panel indices
>>> info(dummy[i,j] [[1]]) # access the list elements
>>>   }, ...)
>>>   })
>>> 
>>> HTH,
>>> 
>>> baptiste
>>> 
>>> 
>>> On 20 April 2011 10:17, Marius Hofert  wrote:
 Dear Baptiste,
 
 there is one tricky part left: how can I create a matrix with the 
 grid.table()
 objects as output? Is this possible? If not, maybe one can try to work with
 panel.splom (which can address single panels and thus call info() for each
 row-column index pair (i,j)), but I'm not sure if this will work.
 
 Cheers,
 
 Marius
 
 library(lattice)
 library(gridExtra)
 
 splom2 <- function(x, a, b, c){
## function for the additional information
info <- function(a., b., c.){ # single values for one panel
grid.table(c(bq

Re: [R] splom, plotmath: how to add three lines of information with alignment?

2011-04-20 Thread baptiste auguie
On 20 April 2011 19:23, Marius Hofert  wrote:
> Dear Baptiste,
>
> thank you for your help. I tried to built in your suggestions into the splom.
> Below is the result. I decided to create the plotmath-expressions outside the
> function splom2, this will allow me later to horizontally shift (via phantom,
> for example) the table entries so that they will be vertically aligned 
> according
> to the "=" signs. Although an array is allowed to contain expressions, I could
> not manage to create it properly. Do you know a solution?
>
> Cheers,
>
> Marius
>
> library(lattice)
> library(grid)
> library(gridExtra)
>
> ## splom with customized lower.panel
> ## x: data
> ## expr.arr: array of expressions [(i,j,) entry contains expressions which are
> ##           plotted in a grid table in the lower panel (i,j)]
> splom2 <- function(x, expr.arr){
>    ## function for creating table
>    table.fun <- function(vec){ # single values for one panel
>        grid.table(vec,
>                   parse=TRUE, # parse labels as expressions
>                   theme=theme.list(
>                   gpar.corefill=gpar(fill=NA, col=NA), # make bg transparent
>                   core.just="left") # justification of labels
>                   )
>    }
>    ## splom
>    splom(x, varname.cex=1.4,
>          superpanel=function(z, ...){
>              panel.pairs(z, upper.panel=panel.splom, 
> lower.panel=function(i,j){
>                  table.fun(expr.arr[i,j,])
>              }, ...)
>          })
> }
>
> ## create data and array of expressions
> d <- 4
> x <- matrix(runif(d*1000), ncol=d)
> expr.arr <- array(, dim=c(d,d,3), dimnames=c("i","j","val")) # d x d x 3 
> elements
> for(i in 1:d){
>    for(j in 1:d){
>        # expr.arr[i,j,] <- expression(italic(a)==0, italic(bbb)==0, 
> italic(c)==0) # does no work
>        expr.arr[i,j,] <- c(bquote(italic(a)==.(0)), 
> bquote(italic(bbb)==.(0)), bquote(italic(c)==.(0))) # same here
>    }
> }
>
> ## plot
> splom2(x, expr.arr)
>

Initializing your array with a list seems to work for whatever reason
that's well above my head,

expr.arr <- array(list(NA,NA,NA), dim=c(d,d,3), dimnames=c("i","j","val"))

As for the alignment, there should be a better way using multiple
columns in grid.table, but parse is struggling to interpret the = sign
on its own. Again, I'm not sure why, this is deep magic to me.


library(gridExtra)
d = matrix(c("italic(a)==phantom('')", round(pi,4),
  "italic(b)==phantom()", round(pi,6)), ncol=2, byrow=T)

grid.table(d, parse=T,theme=theme.list(
  gpar.corefill=gpar(fill=NA, col=NA),
  core.just="left", padding.h = unit(0, "mm") ))

HTH,

baptiste

>
> On 2011-04-20, at 01:33 , baptiste auguie wrote:
>
>> Hi,
>>
>> You may want to wait advice from someone who actually understands (the
>> labyrinth that is) lattice's help for splom, but the following might
>> be a start. I didn't understand what values you actually wanted
>> displayed in the lower triangle panels, so I made up some random ones
>> in a 3x3 matrix of 3-vectors.
>>
>> library(lattice)
>> library(gridExtra)
>>
>> info <- function(x){
>>  grid.table(c(bquote(italic(a)==.(x[1])),
>>               bquote(italic(b)==.(x[2])),
>>               bquote(italic(c)==.(x[3]))),
>>             core.just="left",
>>             parse=TRUE)
>> }
>>
>> U <- matrix(runif(3000), ncol=3)
>>
>> splom(U,
>>     superpanel=function(z, ...){
>>       ## dummy 3x3 matrix of 3 values to diplay
>>       values <- replicate(9, round(rnorm(3), 3), simplify=FALSE)
>>       dummy <- matrix(values, ncol=3, byrow=F)
>>       panel.pairs(z, upper.panel=panel.splom,
>>                   lower.panel=function(i, j, ...){
>>                     print(paste(i,j)) # current panel indices
>>                     info(dummy[i,j] [[1]]) # access the list elements
>>                   }, ...)
>>       })
>>
>> HTH,
>>
>> baptiste
>>
>>
>> On 20 April 2011 10:17, Marius Hofert  wrote:
>>> Dear Baptiste,
>>>
>>> there is one tricky part left: how can I create a matrix with the 
>>> grid.table()
>>> objects as output? Is this possible? If not, maybe one can try to work with
>>> panel.splom (which can address single panels and thus call info() for each
>>> row-column index pair (i,j)), but I'm not sure if this will work.
>>>
>>> Cheers,
>>>
>>> Marius
>>>
>>> library(lattice)
>>> library(gridExtra)
>>>
>>> splom2 <- function(x, a, b, c){
>>>    ## function for the additional information
>>>    info <- function(a., b., c.){ # single values for one panel
>>>        grid.table(c(bquote(italic(a)==.(a.)),
>>>                     bquote(italic(b)==.(b.)),
>>>                     bquote(italic(c)==.(c.))
>>>                     ),
>>>                   parse=TRUE, # parse labels as expressions
>>>                   theme=theme.list(
>>>                   gpar.corefill=gpar(fill=NA, col=NA), # make bg transparent
>>>                   core.just="right") # justification of labels
>>>                   )
>>>    }
>>>    labs <- m

Re: [R] splom, plotmath: how to add three lines of information with alignment?

2011-04-20 Thread Marius Hofert
Dear Baptiste,

thank you for your help. I tried to built in your suggestions into the splom. 
Below is the result. I decided to create the plotmath-expressions outside the 
function splom2, this will allow me later to horizontally shift (via phantom,
for example) the table entries so that they will be vertically aligned 
according 
to the "=" signs. Although an array is allowed to contain expressions, I could 
not manage to create it properly. Do you know a solution?

Cheers,

Marius

library(lattice) 
library(grid)
library(gridExtra)

## splom with customized lower.panel
## x: data
## expr.arr: array of expressions [(i,j,) entry contains expressions which are
##   plotted in a grid table in the lower panel (i,j)]
splom2 <- function(x, expr.arr){
## function for creating table 
table.fun <- function(vec){ # single values for one panel
grid.table(vec,
   parse=TRUE, # parse labels as expressions
   theme=theme.list(
   gpar.corefill=gpar(fill=NA, col=NA), # make bg transparent
   core.just="left") # justification of labels
   ) 
}
## splom
splom(x, varname.cex=1.4,
  superpanel=function(z, ...){
  panel.pairs(z, upper.panel=panel.splom, lower.panel=function(i,j){
  table.fun(expr.arr[i,j,])
  }, ...)
  })
}

## create data and array of expressions
d <- 4
x <- matrix(runif(d*1000), ncol=d)
expr.arr <- array(, dim=c(d,d,3), dimnames=c("i","j","val")) # d x d x 3 
elements
for(i in 1:d){
for(j in 1:d){
# expr.arr[i,j,] <- expression(italic(a)==0, italic(bbb)==0, 
italic(c)==0) # does no work
expr.arr[i,j,] <- c(bquote(italic(a)==.(0)), bquote(italic(bbb)==.(0)), 
bquote(italic(c)==.(0))) # same here
}
}

## plot
splom2(x, expr.arr)


On 2011-04-20, at 01:33 , baptiste auguie wrote:

> Hi,
> 
> You may want to wait advice from someone who actually understands (the
> labyrinth that is) lattice's help for splom, but the following might
> be a start. I didn't understand what values you actually wanted
> displayed in the lower triangle panels, so I made up some random ones
> in a 3x3 matrix of 3-vectors.
> 
> library(lattice)
> library(gridExtra)
> 
> info <- function(x){
>  grid.table(c(bquote(italic(a)==.(x[1])),
>   bquote(italic(b)==.(x[2])),
>   bquote(italic(c)==.(x[3]))),
> core.just="left",
> parse=TRUE)
> }
> 
> U <- matrix(runif(3000), ncol=3)
> 
> splom(U,
> superpanel=function(z, ...){
>   ## dummy 3x3 matrix of 3 values to diplay
>   values <- replicate(9, round(rnorm(3), 3), simplify=FALSE)
>   dummy <- matrix(values, ncol=3, byrow=F)
>   panel.pairs(z, upper.panel=panel.splom,
>   lower.panel=function(i, j, ...){
> print(paste(i,j)) # current panel indices
> info(dummy[i,j] [[1]]) # access the list elements
>   }, ...)
>   })
> 
> HTH,
> 
> baptiste
> 
> 
> On 20 April 2011 10:17, Marius Hofert  wrote:
>> Dear Baptiste,
>> 
>> there is one tricky part left: how can I create a matrix with the 
>> grid.table()
>> objects as output? Is this possible? If not, maybe one can try to work with
>> panel.splom (which can address single panels and thus call info() for each
>> row-column index pair (i,j)), but I'm not sure if this will work.
>> 
>> Cheers,
>> 
>> Marius
>> 
>> library(lattice)
>> library(gridExtra)
>> 
>> splom2 <- function(x, a, b, c){
>>## function for the additional information
>>info <- function(a., b., c.){ # single values for one panel
>>grid.table(c(bquote(italic(a)==.(a.)),
>> bquote(italic(b)==.(b.)),
>> bquote(italic(c)==.(c.))
>> ),
>>   parse=TRUE, # parse labels as expressions
>>   theme=theme.list(
>>   gpar.corefill=gpar(fill=NA, col=NA), # make bg transparent
>>   core.just="right") # justification of labels
>>   )
>>}
>>labs <- matrix(, nrow=ncol(x), ncol=ncol(x)) # should be a matrix of 
>> grid.table() objects
>>for(i in 1:ncol(x)) for(j in 1:ncol(x)) labs[i,j] <- info(a.=a[i,j], 
>> b.=b[i,j], c.=c[i,j])
>>## splom
>>splom(x, superpanel=function(z,...){
>>  df=data.frame(rows=as.vector(row(a)),
>>  columns=as.vector(col(a)), labs=as.vector(labs))
>>  df=subset(df,columns>  with(df,{
>>  panel.text(x=rows, y=columns, labels=labs)
>>  })
>>  panel.pairs(z, upper.panel=panel.splom, 
>> lower.panel=function(...){}, ...)
>>  })
>> }
>> 
>> ## generate data
>> U <- matrix(runif(3000), ncol=3)
>> 
>> ## build information
>> a <- cor(U, method="kendall")
>> b <- diag(ncol=3, nrow=3)
>> c <- diag(ncol=3, nrow=3)
>> 
>> ## plot with information
>> splom2(U, a, b, c)
>> 
>> 
>> 

_

Re: [R] splom, plotmath: how to add three lines of information with alignment?

2011-04-19 Thread baptiste auguie
Hi,

You may want to wait advice from someone who actually understands (the
labyrinth that is) lattice's help for splom, but the following might
be a start. I didn't understand what values you actually wanted
displayed in the lower triangle panels, so I made up some random ones
in a 3x3 matrix of 3-vectors.

library(lattice)
library(gridExtra)

info <- function(x){
  grid.table(c(bquote(italic(a)==.(x[1])),
   bquote(italic(b)==.(x[2])),
   bquote(italic(c)==.(x[3]))),
 core.just="left",
 parse=TRUE)
}

U <- matrix(runif(3000), ncol=3)

splom(U,
 superpanel=function(z, ...){
   ## dummy 3x3 matrix of 3 values to diplay
   values <- replicate(9, round(rnorm(3), 3), simplify=FALSE)
   dummy <- matrix(values, ncol=3, byrow=F)
   panel.pairs(z, upper.panel=panel.splom,
   lower.panel=function(i, j, ...){
 print(paste(i,j)) # current panel indices
 info(dummy[i,j] [[1]]) # access the list elements
   }, ...)
   })

HTH,

baptiste


On 20 April 2011 10:17, Marius Hofert  wrote:
> Dear Baptiste,
>
> there is one tricky part left: how can I create a matrix with the grid.table()
> objects as output? Is this possible? If not, maybe one can try to work with
> panel.splom (which can address single panels and thus call info() for each
> row-column index pair (i,j)), but I'm not sure if this will work.
>
> Cheers,
>
> Marius
>
> library(lattice)
> library(gridExtra)
>
> splom2 <- function(x, a, b, c){
>    ## function for the additional information
>    info <- function(a., b., c.){ # single values for one panel
>        grid.table(c(bquote(italic(a)==.(a.)),
>                     bquote(italic(b)==.(b.)),
>                     bquote(italic(c)==.(c.))
>                     ),
>                   parse=TRUE, # parse labels as expressions
>                   theme=theme.list(
>                   gpar.corefill=gpar(fill=NA, col=NA), # make bg transparent
>                   core.just="right") # justification of labels
>                   )
>    }
>    labs <- matrix(, nrow=ncol(x), ncol=ncol(x)) # should be a matrix of 
> grid.table() objects
>    for(i in 1:ncol(x)) for(j in 1:ncol(x)) labs[i,j] <- info(a.=a[i,j], 
> b.=b[i,j], c.=c[i,j])
>    ## splom
>    splom(x, superpanel=function(z,...){
>              df=data.frame(rows=as.vector(row(a)),
>              columns=as.vector(col(a)), labs=as.vector(labs))
>              df=subset(df,columns              with(df,{
>                  panel.text(x=rows, y=columns, labels=labs)
>              })
>              panel.pairs(z, upper.panel=panel.splom, 
> lower.panel=function(...){}, ...)
>          })
> }
>
> ## generate data
> U <- matrix(runif(3000), ncol=3)
>
> ## build information
> a <- cor(U, method="kendall")
> b <- diag(ncol=3, nrow=3)
> c <- diag(ncol=3, nrow=3)
>
> ## plot with information
> splom2(U, a, b, c)
>
>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] splom, plotmath: how to add three lines of information with alignment?

2011-04-19 Thread Marius Hofert
Dear Baptiste,

there is one tricky part left: how can I create a matrix with the grid.table() 
objects as output? Is this possible? If not, maybe one can try to work with
panel.splom (which can address single panels and thus call info() for each
row-column index pair (i,j)), but I'm not sure if this will work.

Cheers,

Marius

library(lattice)
library(gridExtra)

splom2 <- function(x, a, b, c){
## function for the additional information
info <- function(a., b., c.){ # single values for one panel
grid.table(c(bquote(italic(a)==.(a.)), 
 bquote(italic(b)==.(b.)), 
 bquote(italic(c)==.(c.))
 ),
   parse=TRUE, # parse labels as expressions
   theme=theme.list(
   gpar.corefill=gpar(fill=NA, col=NA), # make bg transparent
   core.just="right") # justification of labels
   ) 
}
labs <- matrix(, nrow=ncol(x), ncol=ncol(x)) # should be a matrix of 
grid.table() objects
for(i in 1:ncol(x)) for(j in 1:ncol(x)) labs[i,j] <- info(a.=a[i,j], 
b.=b[i,j], c.=c[i,j])
## splom
splom(x, superpanel=function(z,...){
  df=data.frame(rows=as.vector(row(a)), 
  columns=as.vector(col(a)), labs=as.vector(labs))
  df=subset(df,columns Hi,
> 
> This is always a challenge with expressions vs calls, etc. grid.table
> expects an input that can be coerced into a matrix of unevaluated
> expressions. This seems to work,
> 
> info <- function(a,b){
>  grid.table(c(bquote(alpha==.(a)), bquote(beta==.(b))),
> parse=TRUE, # parse labels as expressions
> theme=theme.list(
>   gpar.corefill=gpar(fill=NA, col=NA), # make bg transparent
>  core.just="left") # justification of labels
> )
> }
> xyplot(1~1, panel=function(...) info(0.1, 0.5) )
> 
> 
> HTH,
> 
> baptiste
> 
> 
> On 20 April 2011 07:52, Marius Hofert  wrote:
>> Dear guys,
>> 
>> I'm almost there... how can I fix the final problems?
>> 
>> Cheers,
>> 
>> Marius
>> 
>> PS: the "info" function is the one I will then try to call within splom...
>> 
>> library(lattice)
>> library(gridExtra)
>> 
>> ## trial 1
>> info <- function(a,b){
>>grid.table(as.expression(substitute(expression(alpha==alph, beta==bet),
>>list(alph=a, bet=b))),
>>   parse=TRUE, # parse labels as expressions
>>   theme=theme.list(
>>   gpar.corefill=gpar(fill=NA, col=NA), # make bg transparent
>>   core.just="left") # justification of labels
>>   )
>> }
>> xyplot(1~1, panel=function(...) info(0.1, 0.5) )
>> 
>> ## trial 2
>> info <- function(a,b){
>>grid.table(substitute(expression(alpha==alph, beta==bet),
>>list(alph=a, bet=b)),
>>   parse=TRUE, # parse labels as expressions
>>   theme=theme.list(
>>   gpar.corefill=gpar(fill=NA, col=NA), # make bg transparent
>>   core.just="left") # justification of labels
>>   )
>> }
>> xyplot(1~1, panel=function(...) info(0.1, 0.5) )
>> 
>> 
>> 
>> On 2011-04-19, at 21:39 , David Winsemius wrote:
>> 
>>> 
>>> On Apr 19, 2011, at 3:26 PM, baptiste auguie wrote:
>>> 
 I'm hoping to release a new version on CRAN soon; the broken state of
 R-forge and my poor understanding of R CMD CHECK results have often
 made me postpone action indefinitely.
>>> 
>>> In this case the errors were all mine. I suppose an even earlier stage 
>>> newbie than I might have problems not knowing that binary packages were not 
>>> available on r-forge or in recognizing (eventually) that loaded old 
>>> packages might prevent new versions from loading. Figuring out how to clear 
>>> one package from all the various places they can reside is beyond my pay 
>>> grade, so I just restart. Someone should write a flush.package function :-)
>>> 
>>> --
>>> david.
>>> 
 
 Best,
 
 baptiste
 
 On 19 April 2011 22:32, David Winsemius  wrote:
> I attempted , mostly with success to install following the directions in
> r-forge webpage.
> 
> I did add type="source", since generally r-forge does not have compiled
> binaries and I did need to do it twice since I did not have `brew` 
> installed
> under 2.13.0(beta). The loading of help seemed to be a problem which I
> initially assumed to be due to my being on a Mac running R 2.13.0(beta).
> When issuing ?gridExtra I get a help page that says: Error in fetch(key) :
> internal error -3 in R_decompress1
> 
> (I did not expect to ?gridExtra to work since I generally use
> help(package=gridExtra) for packages, but when i do that I get:
>> help(package=gridExtra)
> Error in formatDL(nm, txt, indent = max(nchar(nm, "w")) + 3) :
> incorrect values of 'indent' and 'width'
> 
> Then I realized I was loading a new package on top of an old loaded 
> package
> so 

Re: [R] splom, plotmath: how to add three lines of information with alignment?

2011-04-19 Thread baptiste auguie
Hi,

This is always a challenge with expressions vs calls, etc. grid.table
expects an input that can be coerced into a matrix of unevaluated
expressions. This seems to work,

info <- function(a,b){
  grid.table(c(bquote(alpha==.(a)), bquote(beta==.(b))),
 parse=TRUE, # parse labels as expressions
 theme=theme.list(
   gpar.corefill=gpar(fill=NA, col=NA), # make bg transparent
  core.just="left") # justification of labels
 )
}
xyplot(1~1, panel=function(...) info(0.1, 0.5) )


HTH,

baptiste


On 20 April 2011 07:52, Marius Hofert  wrote:
> Dear guys,
>
> I'm almost there... how can I fix the final problems?
>
> Cheers,
>
> Marius
>
> PS: the "info" function is the one I will then try to call within splom...
>
> library(lattice)
> library(gridExtra)
>
> ## trial 1
> info <- function(a,b){
>    grid.table(as.expression(substitute(expression(alpha==alph, beta==bet),
>        list(alph=a, bet=b))),
>               parse=TRUE, # parse labels as expressions
>               theme=theme.list(
>               gpar.corefill=gpar(fill=NA, col=NA), # make bg transparent
>               core.just="left") # justification of labels
>               )
> }
> xyplot(1~1, panel=function(...) info(0.1, 0.5) )
>
> ## trial 2
> info <- function(a,b){
>    grid.table(substitute(expression(alpha==alph, beta==bet),
>        list(alph=a, bet=b)),
>               parse=TRUE, # parse labels as expressions
>               theme=theme.list(
>               gpar.corefill=gpar(fill=NA, col=NA), # make bg transparent
>               core.just="left") # justification of labels
>               )
> }
> xyplot(1~1, panel=function(...) info(0.1, 0.5) )
>
>
>
> On 2011-04-19, at 21:39 , David Winsemius wrote:
>
>>
>> On Apr 19, 2011, at 3:26 PM, baptiste auguie wrote:
>>
>>> I'm hoping to release a new version on CRAN soon; the broken state of
>>> R-forge and my poor understanding of R CMD CHECK results have often
>>> made me postpone action indefinitely.
>>
>> In this case the errors were all mine. I suppose an even earlier stage 
>> newbie than I might have problems not knowing that binary packages were not 
>> available on r-forge or in recognizing (eventually) that loaded old packages 
>> might prevent new versions from loading. Figuring out how to clear one 
>> package from all the various places they can reside is beyond my pay grade, 
>> so I just restart. Someone should write a flush.package function :-)
>>
>> --
>> david.
>>
>>>
>>> Best,
>>>
>>> baptiste
>>>
>>> On 19 April 2011 22:32, David Winsemius  wrote:
 I attempted , mostly with success to install following the directions in
 r-forge webpage.

 I did add type="source", since generally r-forge does not have compiled
 binaries and I did need to do it twice since I did not have `brew` 
 installed
 under 2.13.0(beta). The loading of help seemed to be a problem which I
 initially assumed to be due to my being on a Mac running R 2.13.0(beta).
 When issuing ?gridExtra I get a help page that says: Error in fetch(key) :
 internal error -3 in R_decompress1

 (I did not expect to ?gridExtra to work since I generally use
 help(package=gridExtra) for packages, but when i do that I get:
> help(package=gridExtra)
 Error in formatDL(nm, txt, indent = max(nchar(nm, "w")) + 3) :
 incorrect values of 'indent' and 'width'

 Then I realized I was loading a new package on top of an old loaded package
 so I restarted R and none of the help errors returned.

 Nice text table. Should make this task a lot easier that the strategy I was
 about to suggest of doing some sort of superpose of multiple panel.text
 calls.

 --
 David


 On Apr 19, 2011, at 1:19 AM, baptiste auguie wrote:

> On 19 April 2011 17:06, Marius Hofert  wrote:
>>
>> Dear Baptiste,
>>
>> thanks for your answer.
>> Unfortunately, I get the error "Error using packet 1 invalid 'times'
>> argument" when executing your code. Hmm... not sure where the problem is.
>>
>
> Oops, – sorry, my mistake. For this code to work you'll need a more
> recent version of gridExtra than the one on CRAN. You can get it here:
> http://code.google.com/p/gridextra/
>
> baptiste
>
>> Cheers,
>>
>> Marius
>>
>> On 2011-04-19, at 24:03 , baptiste auguie wrote:
>>
>>> Hi,
>>>
>>> Does this help?
>>>
>>> library(gridExtra)
>>>
>>> my.title = function(expressions) {
>>> grid.table(expressions, parse=TRUE,
>>>           theme=theme.list(gpar.corefill = gpar(fill = NA, col = NA),
>>>             core.just = "left"))
>>> }
>>>
>>> e = expression(alpha,"text", italic(italic),
>>>  hat(beta), integral(f(x)*dx, a, b))
>>>
>>> library(lattice)
>>>
>>> xyplot(1~1, panel=function(...) my.title(e) )
>>>
>>> HTH,
>>>
>>> baptiste
>>>

Re: [R] splom, plotmath: how to add three lines of information with alignment?

2011-04-19 Thread Marius Hofert
Dear guys,

I'm almost there... how can I fix the final problems?

Cheers,

Marius

PS: the "info" function is the one I will then try to call within splom... 

library(lattice)
library(gridExtra)

## trial 1
info <- function(a,b){ 
grid.table(as.expression(substitute(expression(alpha==alph, beta==bet), 
list(alph=a, bet=b))), 
   parse=TRUE, # parse labels as expressions
   theme=theme.list(
   gpar.corefill=gpar(fill=NA, col=NA), # make bg transparent
   core.just="left") # justification of labels
   ) 
}
xyplot(1~1, panel=function(...) info(0.1, 0.5) )

## trial 2
info <- function(a,b){ 
grid.table(substitute(expression(alpha==alph, beta==bet), 
list(alph=a, bet=b)), 
   parse=TRUE, # parse labels as expressions
   theme=theme.list(
   gpar.corefill=gpar(fill=NA, col=NA), # make bg transparent
   core.just="left") # justification of labels
   ) 
}
xyplot(1~1, panel=function(...) info(0.1, 0.5) )



On 2011-04-19, at 21:39 , David Winsemius wrote:

> 
> On Apr 19, 2011, at 3:26 PM, baptiste auguie wrote:
> 
>> I'm hoping to release a new version on CRAN soon; the broken state of
>> R-forge and my poor understanding of R CMD CHECK results have often
>> made me postpone action indefinitely.
> 
> In this case the errors were all mine. I suppose an even earlier stage newbie 
> than I might have problems not knowing that binary packages were not 
> available on r-forge or in recognizing (eventually) that loaded old packages 
> might prevent new versions from loading. Figuring out how to clear one 
> package from all the various places they can reside is beyond my pay grade, 
> so I just restart. Someone should write a flush.package function :-)
> 
> -- 
> david.
> 
>> 
>> Best,
>> 
>> baptiste
>> 
>> On 19 April 2011 22:32, David Winsemius  wrote:
>>> I attempted , mostly with success to install following the directions in
>>> r-forge webpage.
>>> 
>>> I did add type="source", since generally r-forge does not have compiled
>>> binaries and I did need to do it twice since I did not have `brew` installed
>>> under 2.13.0(beta). The loading of help seemed to be a problem which I
>>> initially assumed to be due to my being on a Mac running R 2.13.0(beta).
>>> When issuing ?gridExtra I get a help page that says: Error in fetch(key) :
>>> internal error -3 in R_decompress1
>>> 
>>> (I did not expect to ?gridExtra to work since I generally use
>>> help(package=gridExtra) for packages, but when i do that I get:
 help(package=gridExtra)
>>> Error in formatDL(nm, txt, indent = max(nchar(nm, "w")) + 3) :
>>> incorrect values of 'indent' and 'width'
>>> 
>>> Then I realized I was loading a new package on top of an old loaded package
>>> so I restarted R and none of the help errors returned.
>>> 
>>> Nice text table. Should make this task a lot easier that the strategy I was
>>> about to suggest of doing some sort of superpose of multiple panel.text
>>> calls.
>>> 
>>> --
>>> David
>>> 
>>> 
>>> On Apr 19, 2011, at 1:19 AM, baptiste auguie wrote:
>>> 
 On 19 April 2011 17:06, Marius Hofert  wrote:
> 
> Dear Baptiste,
> 
> thanks for your answer.
> Unfortunately, I get the error "Error using packet 1 invalid 'times'
> argument" when executing your code. Hmm... not sure where the problem is.
> 
 
 Oops, – sorry, my mistake. For this code to work you'll need a more
 recent version of gridExtra than the one on CRAN. You can get it here:
 http://code.google.com/p/gridextra/
 
 baptiste
 
> Cheers,
> 
> Marius
> 
> On 2011-04-19, at 24:03 , baptiste auguie wrote:
> 
>> Hi,
>> 
>> Does this help?
>> 
>> library(gridExtra)
>> 
>> my.title = function(expressions) {
>> grid.table(expressions, parse=TRUE,
>>   theme=theme.list(gpar.corefill = gpar(fill = NA, col = NA),
>> core.just = "left"))
>> }
>> 
>> e = expression(alpha,"text", italic(italic),
>>  hat(beta), integral(f(x)*dx, a, b))
>> 
>> library(lattice)
>> 
>> xyplot(1~1, panel=function(...) my.title(e) )
>> 
>> HTH,
>> 
>> baptiste
>> 
>> 
>> 
>> On 19 April 2011 08:43, Marius Hofert  wrote:
>>> 
>>> Dear expeRts,
>>> 
>>> I would like to create a scatter plot matrix with splom(). The lower
>>> panel should
>>> contain some additional information about the samples shown in the
>>> upper panel
>>> plot, see the splom() call below. Now two questions came up:
>>> (1) The lower panels show "tau" and "alpha" on top of each other. How
>>> can I plot
>>> *three* expressions on top of each other? I tried several approaches
>>> (see the trials below),
>>> but couldn't manage to get this to work properly.
>>> (2) Is there the possibility to plot the two/three lines (containing
>>

Re: [R] splom, plotmath: how to add three lines of information with alignment?

2011-04-18 Thread baptiste auguie
On 19 April 2011 17:06, Marius Hofert  wrote:
> Dear Baptiste,
>
> thanks for your answer.
> Unfortunately, I get the error "Error using packet 1 invalid 'times' 
> argument" when executing your code. Hmm... not sure where the problem is.
>

Oops, – sorry, my mistake. For this code to work you'll need a more
recent version of gridExtra than the one on CRAN. You can get it here:
http://code.google.com/p/gridextra/

baptiste

> Cheers,
>
> Marius
>
> On 2011-04-19, at 24:03 , baptiste auguie wrote:
>
>> Hi,
>>
>> Does this help?
>>
>> library(gridExtra)
>>
>> my.title = function(expressions) {
>>  grid.table(expressions, parse=TRUE,
>>             theme=theme.list(gpar.corefill = gpar(fill = NA, col = NA),
>>               core.just = "left"))
>> }
>>
>> e = expression(alpha,"text", italic(italic),
>>    hat(beta), integral(f(x)*dx, a, b))
>>
>> library(lattice)
>>
>> xyplot(1~1, panel=function(...) my.title(e) )
>>
>> HTH,
>>
>> baptiste
>>
>>
>>
>> On 19 April 2011 08:43, Marius Hofert  wrote:
>>> Dear expeRts,
>>>
>>> I would like to create a scatter plot matrix with splom(). The lower panel 
>>> should
>>> contain some additional information about the samples shown in the upper 
>>> panel
>>> plot, see the splom() call below. Now two questions came up:
>>> (1) The lower panels show "tau" and "alpha" on top of each other. How can I 
>>> plot
>>> *three* expressions on top of each other? I tried several approaches (see 
>>> the trials below),
>>> but couldn't manage to get this to work properly.
>>> (2) Is there the possibility to plot the two/three lines (containing "tau = 
>>> ..", "alpha = ..")
>>> aligend according to the equality sign?
>>>
>>> Cheers,
>>>
>>> Marius
>>>
>>>
>>> library(lattice)
>>>
>>> f <- function(i,j) i+j
>>>
>>> U <- matrix(runif(3000), ncol=3)
>>>
>>> splom(U,
>>>      superpanel=function(z, ...){
>>>          tau <- cor(U, method="kendall")
>>>          df=data.frame(rows=as.vector(row(tau)), 
>>> columns=as.vector(col(tau)),
>>>          vals=as.vector(tau)) # data frame of row indices, column indices, 
>>> and tau values
>>>          df=subset(df,columns>>          with(df,{
>>>              panel.text(x=rows, y=columns,
>>>                         labels=as.expression(unlist(lapply(1:length(vals),
>>>                             function(i) 
>>> substitute(atop(tau==tau.,alpha==alpha.),
>>>                                                    list(tau.=vals[i], 
>>> alpha.=round(vals[i],3)) ) ))) )
>>>          })
>>>          panel.pairs(z, upper.panel=panel.splom, 
>>> lower.panel=function(...){}, ...)
>>>      })
>>>
>>> ## some minimal "trial" examples:
>>> plot(0,0,main=paste("alpha=1","\n","beta=2","\n","gamma=3",sep=""))
>>> plot(0,0,main=expression(atop(atop(alpha==1, beta==2), gamma==3)))
>>> plot(0,0,main=paste(expression(alpha==1),"\n",expression(beta==2),"\n",
>>>         expression(gamma==3), sep=""))
>>> plot(0,0,main=substitute(paste(alpha==1,x,beta==2,x,
>>>         gamma==3, sep=""), list(x="\n")))
>>> plot(0,0,main=expression(cat(alpha==1, "\n", beta==2, "\n", gamma==3, 
>>> sep="")))
>>> plot(0,0,main=cat(expression(alpha==1), "\n", expression(beta==2), "\n",
>>>         expression(gamma==3), sep=""))
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] splom, plotmath: how to add three lines of information with alignment?

2011-04-18 Thread baptiste auguie
Hi,

Does this help?

library(gridExtra)

my.title = function(expressions) {
  grid.table(expressions, parse=TRUE,
 theme=theme.list(gpar.corefill = gpar(fill = NA, col = NA),
   core.just = "left"))
}

e = expression(alpha,"text", italic(italic),
hat(beta), integral(f(x)*dx, a, b))

library(lattice)

xyplot(1~1, panel=function(...) my.title(e) )

HTH,

baptiste



On 19 April 2011 08:43, Marius Hofert  wrote:
> Dear expeRts,
>
> I would like to create a scatter plot matrix with splom(). The lower panel 
> should
> contain some additional information about the samples shown in the upper panel
> plot, see the splom() call below. Now two questions came up:
> (1) The lower panels show "tau" and "alpha" on top of each other. How can I 
> plot
> *three* expressions on top of each other? I tried several approaches (see the 
> trials below),
> but couldn't manage to get this to work properly.
> (2) Is there the possibility to plot the two/three lines (containing "tau = 
> ..", "alpha = ..")
> aligend according to the equality sign?
>
> Cheers,
>
> Marius
>
>
> library(lattice)
>
> f <- function(i,j) i+j
>
> U <- matrix(runif(3000), ncol=3)
>
> splom(U,
>      superpanel=function(z, ...){
>          tau <- cor(U, method="kendall")
>          df=data.frame(rows=as.vector(row(tau)), columns=as.vector(col(tau)),
>          vals=as.vector(tau)) # data frame of row indices, column indices, 
> and tau values
>          df=subset(df,columns          with(df,{
>              panel.text(x=rows, y=columns,
>                         labels=as.expression(unlist(lapply(1:length(vals),
>                             function(i) 
> substitute(atop(tau==tau.,alpha==alpha.),
>                                                    list(tau.=vals[i], 
> alpha.=round(vals[i],3)) ) ))) )
>          })
>          panel.pairs(z, upper.panel=panel.splom, lower.panel=function(...){}, 
> ...)
>      })
>
> ## some minimal "trial" examples:
> plot(0,0,main=paste("alpha=1","\n","beta=2","\n","gamma=3",sep=""))
> plot(0,0,main=expression(atop(atop(alpha==1, beta==2), gamma==3)))
> plot(0,0,main=paste(expression(alpha==1),"\n",expression(beta==2),"\n",
>         expression(gamma==3), sep=""))
> plot(0,0,main=substitute(paste(alpha==1,x,beta==2,x,
>         gamma==3, sep=""), list(x="\n")))
> plot(0,0,main=expression(cat(alpha==1, "\n", beta==2, "\n", gamma==3, 
> sep="")))
> plot(0,0,main=cat(expression(alpha==1), "\n", expression(beta==2), "\n",
>         expression(gamma==3), sep=""))
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] splom, plotmath: how to add three lines of information with alignment?

2011-04-18 Thread David Winsemius


On Apr 18, 2011, at 4:43 PM, Marius Hofert wrote:


Dear expeRts,

I would like to create a scatter plot matrix with splom(). The lower  
panel should
contain some additional information about the samples shown in the  
upper panel

plot, see the splom() call below. Now two questions came up:
(1) The lower panels show "tau" and "alpha" on top of each other.  
How can I plot
*three* expressions on top of each other? I tried several approaches  
(see the trials below),

but couldn't manage to get this to work properly.
(2) Is there the possibility to plot the two/three lines (containing  
"tau = ..", "alpha = ..")

aligend according to the equality sign?

Cheers,

Marius


library(lattice)

f <- function(i,j) i+j

U <- matrix(runif(3000), ncol=3)

splom(U,
 superpanel=function(z, ...){
 tau <- cor(U, method="kendall")
 df=data.frame(rows=as.vector(row(tau)),  
columns=as.vector(col(tau)),
 vals=as.vector(tau)) # data frame of row indices, column  
indices, and tau values

 df=subset(df,columns 
labels=as.expression(unlist(lapply(1:length(vals),
function(i)  
substitute(atop(tau==tau.,alpha==alpha.),

list(tau.=vals[i], alpha.=round(vals[i],3)) ) ))) )

 })
 panel.pairs(z, upper.panel=panel.splom,  
lower.panel=function(...){}, ...)

 })

## some minimal "trial" examples:


Try instead:   ( As far as I can tell there is no  in  
plotmath.)


> plot(0,0)
> title(main=expression(alpha==1), line=3)
> title(main=expression(beta==2), line=2)
> title(main=expression(gamma==3), line=1)


plot(0,0,main=paste("alpha=1","\n","beta=2","\n","gamma=3",sep=""))
plot(0,0,main=expression(atop(atop(alpha==1, beta==2), gamma==3)))
plot 
(0,0,main=paste(expression(alpha==1),"\n",expression(beta==2),"\n",

expression(gamma==3), sep=""))
plot(0,0,main=substitute(paste(alpha==1,x,beta==2,x,
gamma==3, sep=""), list(x="\n")))
plot(0,0,main=expression(cat(alpha==1, "\n", beta==2, "\n",  
gamma==3, sep="")))
plot(0,0,main=cat(expression(alpha==1), "\n", expression(beta==2),  
"\n",

expression(gamma==3), sep=""))


--
David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] splom, plotmath: how to add three lines of information with alignment?

2011-04-18 Thread Marius Hofert
Dear expeRts,

I would like to create a scatter plot matrix with splom(). The lower panel 
should 
contain some additional information about the samples shown in the upper panel 
plot, see the splom() call below. Now two questions came up:
(1) The lower panels show "tau" and "alpha" on top of each other. How can I 
plot 
*three* expressions on top of each other? I tried several approaches (see the 
trials below),
but couldn't manage to get this to work properly.
(2) Is there the possibility to plot the two/three lines (containing "tau = 
..", "alpha = ..")
aligend according to the equality sign?

Cheers,

Marius


library(lattice)

f <- function(i,j) i+j

U <- matrix(runif(3000), ncol=3)

splom(U, 
  superpanel=function(z, ...){
  tau <- cor(U, method="kendall")
  df=data.frame(rows=as.vector(row(tau)), columns=as.vector(col(tau)),
  vals=as.vector(tau)) # data frame of row indices, column indices, and 
tau values
  df=subset(df,columnshttps://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.