Re: [R] add outer strip for levels in lattice plot (useOuterStrips alternative for Lattice)

2015-07-11 Thread Luigi Marongiu
Dear Duncan,
I tried the solution you indicated in the previous message but I am
still obtaining the error length(dimx) == 2 is not TRUE. Assuming that
the dataframe is working (it does work on my machine), I added the
useOuterStrips bit as you showed:
useOuterStrips(
strip = strip.custom(
factor.levels = paste(column,1:6),
par.strip.text = list(cex = 0.75)),
strip.left = strip.custom(factor.levels = paste(row, 1:2),
  horizontal = FALSE,
  par.strip.text = list(cex = 0.75)
  ),
   xyplot(Rn ~ Cycle | Well,
   data = my.data,
   groups = Well,
   ylab= Y axis,
   xlab=X axis,
   main=Title,
   scales = list(
   x = list(draw = FALSE),
   y = list(draw = FALSE),
   relation=same
   ),
   as.table = TRUE,
   layout = L,
   par.settings = list(
   strip.background=list(col=white),
   axis.text = list(cex = 0.6),
   par.xlab.text = list(cex = 0.75),
   par.ylab.text = list(cex = 0.75),
   par.main.text = list(cex = 0.8),
   superpose.symbol = list(pch = ., cex = 1)
   ),
   strip= FALSE,
   type = l,
   col = 3,
   panel = panel.superpose
)
)

WHere am I getting it wrong?
Best regards
Luigi


On Thu, Jul 9, 2015 at 11:36 AM, Duncan Mackay dulca...@bigpond.com wrote:
 Hi Luigi

 If you wanted to add some text you could use grid.text from the grid package

 I use it regularly for annotating

 See also
 https://stat.ethz.ch/pipermail/r-help/2005-February/066264.html

 https://stat.ethz.ch/pipermail/r-help/2005-April/069456.html



 Duncan

 -Original Message-
 From: Luigi Marongiu [mailto:marongiu.lu...@gmail.com]
 Sent: Thursday, 9 July 2015 19:01
 To: Duncan Mackay
 Subject: Re: [R] add outer strip for levels in lattice plot (useOuterStrips 
 alternative for Lattice)

 Dear Duncan,
 funny this deviation of the variables outcomes. yesterday when i wrote
 the script it worked fine and even today when i loaded it on rstudio
 at work i obtained:
 Cycle  num[1:540]
 Linenum[1:540]
 Rn  num[1:540]
 Target chr[1:540]
 Wellnum[1:540]
 my.data 540 obs. of 4 variables
 and the call for my.data returned a proper dataframe.
 I did not write  lattice_Extra but latticeextra's useOuterStrips()
 [forgot to capitalize the second E].
 I'll try your suggestion, but essentially wouldn't be possible to
 write some text on the top and left portions of the xyplot graph using
 some text function within lattice itself without having to call
 latticeExtra?
 Many thanks
 regards
 Luigi


 On Thu, Jul 9, 2015 at 3:56 AM, Duncan Mackay dulca...@bigpond.com wrote:
 Hi Luigi

 str(my.data)
 'data.frame':   540 obs. of  4 variables:
  $ Line  : chr  1 2 3 4 ...
  $ Well  : chr  1 1 1 1 ...
  $ Target: chr  alpha alpha alpha alpha ...
  $ Rn: chr  0.728 0.735 0.749 0.758 ...

 You didnot create the data.frame properly

 mydata -
 data.frame(Line=Line, Well=Well, Target=Target, Rn=Rn,Cycle= Cycle)
 str(mydata)
 'data.frame':   540 obs. of  4 variables:
  $ Line  : num  1 2 3 4 5 6 7 8 9 10 ...
  $ Well  : num  1 1 1 1 1 1 1 1 1 1 ...
  $ Target: chr  alpha alpha alpha alpha ...
  $ Rn: num  0.728 0.735 0.749 0.758 0.77 0.778 0.78 0.784 0.786 0.785 ...

 I was having problems with your script so I started with the basics (before 
 I found the problem with the df)

 xyplot(Rn ~ Cycle | sprintf(%2d,Well), data = mydata,
as.table = TRUE,
layout = c(6,2),
groups = Well)

 You are not splitting up the data with groups being the same as the 
 conditioning.
 It can be necessary to use this setup in some cases but not this.

 latticeExtra is on Cran so you can use install.packages(latticeExtra) or 
 use the menu
 I have never heard of lattice_Extra


 mydata$rown - ifelse(mydata$Well6,2,1)
 mydata$welln - rep(1:6, 2)[sapply(mydata$Well, pmatch, 1:12)]


 useOuterStrips(strip  = strip.custom(factor.levels = paste(column,1:6),
  par.strip.text = list(cex = 0.75)),
strip.left = strip.custom(factor.levels = paste(row, 1:2),
  horizontal = FALSE,
  par.strip.text = list(cex = 0.75)),

 xyplot(Rn ~ Cycle | welln*rown, data = mydata,
as.table = TRUE,
layout = c(6,2)
   )

 ) ## useOuterStrips

   ps.Colours -
   c(#00,#FF,#00FF00,#FF,#FFA54F,
 #00,#FF00FF,#C0,#00B414,#FFD18F,
 #00B2EE,#ffe5cc,#6A5ACD,#C0C0C0,#CC,
 #6495ED,#FFFAFA)



 useOuterStrips(strip  = strip.custom(factor.levels = paste(column,1:6),
  par.strip.text = list(cex = 0.75)),
strip.left = strip.custom(factor.levels = paste(row, 1:2),
  horizontal = FALSE

Re: [R] add outer strip for levels in lattice plot (useOuterStrips alternative for Lattice)

2015-07-08 Thread Duncan Mackay
Hi Luigi

str(my.data)
'data.frame':   540 obs. of  4 variables:
 $ Line  : chr  1 2 3 4 ...
 $ Well  : chr  1 1 1 1 ...
 $ Target: chr  alpha alpha alpha alpha ...
 $ Rn: chr  0.728 0.735 0.749 0.758 ...

You didnot create the data.frame properly

mydata -
data.frame(Line=Line, Well=Well, Target=Target, Rn=Rn,Cycle= Cycle)
str(mydata)
'data.frame':   540 obs. of  4 variables:
 $ Line  : num  1 2 3 4 5 6 7 8 9 10 ...
 $ Well  : num  1 1 1 1 1 1 1 1 1 1 ...
 $ Target: chr  alpha alpha alpha alpha ...
 $ Rn: num  0.728 0.735 0.749 0.758 0.77 0.778 0.78 0.784 0.786 0.785 ...

I was having problems with your script so I started with the basics (before I 
found the problem with the df)

xyplot(Rn ~ Cycle | sprintf(%2d,Well), data = mydata,
   as.table = TRUE,
   layout = c(6,2),
   groups = Well)

You are not splitting up the data with groups being the same as the 
conditioning.
It can be necessary to use this setup in some cases but not this.

latticeExtra is on Cran so you can use install.packages(latticeExtra) or use 
the menu
I have never heard of lattice_Extra


mydata$rown - ifelse(mydata$Well6,2,1)
mydata$welln - rep(1:6, 2)[sapply(mydata$Well, pmatch, 1:12)]


useOuterStrips(strip  = strip.custom(factor.levels = paste(column,1:6),
 par.strip.text = list(cex = 0.75)),
   strip.left = strip.custom(factor.levels = paste(row, 1:2),
 horizontal = FALSE,
 par.strip.text = list(cex = 0.75)),

xyplot(Rn ~ Cycle | welln*rown, data = mydata,
   as.table = TRUE,
   layout = c(6,2)
  )

) ## useOuterStrips

  ps.Colours -
  c(#00,#FF,#00FF00,#FF,#FFA54F,
#00,#FF00FF,#C0,#00B414,#FFD18F,
#00B2EE,#ffe5cc,#6A5ACD,#C0C0C0,#CC,
#6495ED,#FFFAFA)



useOuterStrips(strip  = strip.custom(factor.levels = paste(column,1:6),
 par.strip.text = list(cex = 0.75)),
   strip.left = strip.custom(factor.levels = paste(row, 1:2),
 horizontal = FALSE,
 par.strip.text = list(cex = 0.75)),

xyplot(Rn ~ Cycle | welln*rown, data = mydata,
   as.table = TRUE,
   groups = Well,
   col = ps.Colours,
   layout = c(6,2)
  )

) ## useOuterStrips

Duncan

-Original Message-
From: Luigi Marongiu [mailto:marongiu.lu...@gmail.com] 
Sent: Thursday, 9 July 2015 09:22
To: Duncan Mackay; Dennis Murphy; r-help
Subject: Re: [R] add outer strip for levels in lattice plot (useOuterStrips 
alternative for Lattice)

In relation to this question I have prepared a workable example. First
I prepare a dataframe with three variables (Cycle, Target, Rn), then I
plot the results with lattice's xyplot(). I won't use the scales but
only the labels and the panels are NOT indicated by the variable Well.
What I would need to use are instead the vectors row.name and col.name
that can identify each column and row of the plot.
Secondly I create replicates of the row.name and col.name in order to
fit the data and create a second dataframe, then I plot using lattice
extra's useOuterStrips().
However (a) I think the call is wrong anyway, (b) I obtain Error:
length(dimx) == 2 is not TRUE (c) I need a package on top of lattice
(d) I might introduce errors during the creation of the second
dataframe.
The requirements remains to create a strip on the top and left side of
the plot to allocate the elements of row.name and col.name possibly
using lattice only.
Thank you for your help.
Luigi


Line-c(1,2,3,4,5,6,7,8,9,10,
  11,12,13,14,15,16,17,18,19,20,
 21,22,23,24,25,26,27,28,29,30,
31,32,33,34,35,36,37,38,39,40,
41,42,43,44,45,46,47,48,49,50,
51,52,53,54,55,56,57,58,59,60,
61,62,63,64,65,66,67,68,69,70,
71,72,73,74,75,76,77,78,79,80,
81,82,83,84,85,86,87,88,89,90,
91,92,93,94,95,96,97,98,99,100,
101,102,103,104,105,106,107,108,109,
 110,111,112,113,114,115,116,117,118,
  119,120,121,122,123,124,125,126,127,
   128,129,130,131,132,133,134,135,
136,137,138,139,140,141,142,143,144,
 145,146,147,148,149,150,151,152,153,
  154,155,156,157,158,159,160,161,162,
   163,164,165,166,167,168,169,170,
171,172,173,174,175,176,177,178,179

Re: [R] add outer strip for levels in lattice plot (useOuterStrips alternative for Lattice)

2015-07-08 Thread Luigi Marongiu
,1.241,1.234,1.228,
1.222,1.216,1.213,1.208,1.205,1.2,1.197,
1.192,1.189,1.186,1.184,1.182,1.181,1.178,
1.178,0.802,0.801,0.801,0.8,0.799,0.797,
0.794,0.791,0.785,0.781,0.777,0.772,0.766,
0.76,0.756,0.753,0.751,0.746,0.742,0.739,
0.735,0.732,0.728,0.726,0.725,0.722,0.718,
0.717,0.716,0.715,0.71,0.709,0.711,0.71,
0.709,0.709,0.709,0.709,0.708,0.709,0.71,
0.71,0.711,0.711,0.712,1.209,1.206,1.204,
1.202,1.197,1.186,1.175,1.165,1.154,1.143,
1.133,1.12,1.11,1.105,1.098,1.091,1.085,
1.078,1.072,1.067,1.063,1.054,1.049,1.048,
1.04,1.036,1.033,1.029,1.027,1.024,1.021,
1.019,1.017,1.013,1.01,1.008,1.006,1.005,
1.004,1.002,1.002,1.001,1,0.998,0.995,
2.936,2.942,2.946,2.951,2.956,2.956,2.968,
2.964,2.953,2.945,2.939,2.929,2.919,2.909,
2.902,2.893,2.882,2.871,2.857,2.847,2.835,
2.825,2.819,2.806,2.795,2.787,2.781,2.766,
2.761,2.752,2.749,2.74,2.731,2.722,2.718,
2.711,2.705,2.7,2.693,2.69,2.686,2.676,
2.672,2.668,2.667,1.032,1.033,1.031,1.033,
1.031,1.029,1.025,1.02,1.019,1.016,1.012,
1.008,1.007,1.011,1.015,1.032,1.068,1.124,
1.209,1.327,1.472,1.632,1.8,1.971,2.14,
2.302,2.459,2.612,2.754,2.886,3.008,3.122,
3.218,3.306,3.39,3.472,3.547,3.613,3.674,
3.731,3.772,3.81,3.84,3.86,3.882,0.808,
0.808,0.808,0.807,0.805,0.804,0.802,0.801,
0.798,0.796,0.794,0.79,0.788,0.785,0.781,
0.78,0.777,0.774,0.772,0.771,0.769,0.767,
0.767,0.766,0.766,0.764,0.764,0.765,0.762,
0.762,0.76,0.759,0.759,0.758,0.758,0.758,
0.756,0.754,0.754,0.753,0.754,0.755,0.753,
0.754,0.753)

my.data - as.data.frame(cbind(Line, Well, Target, Rn))

L - c(6,2)
row.name - c(A, B)
col.name - 1:6


library(lattice)
xyplot(Rn ~ Cycle | Well,
   data = my.data,
   groups = Well,
   ylab= Y axis,
   xlab=X axis,
   main=Title,
   scales = list(
   x = list(draw = FALSE),
   y = list(draw = FALSE),
   relation=same
   ),
   as.table = TRUE,
   layout = L,
   par.settings = list(
   strip.background=list(col=white),
   axis.text = list(cex = 0.6),
   par.xlab.text = list(cex = 0.75),
   par.ylab.text = list(cex = 0.75),
   par.main.text = list(cex = 0.8),
   superpose.symbol = list(pch = ., cex = 1)
   ),
   strip= FALSE,
   type = l,
   col = 3,
   panel = panel.superpose
)


ROW - c(rep(row.name[1], 45*6), rep(row.name[2], 45*6))
CO - c(rep(col.name[1], 45),
rep(col.name[2], 45),
rep(col.name[3], 45),
rep(col.name[4], 45),
rep(col.name[5], 45),
rep(col.name[6], 45)
)
COL - rep(CO,2)
new.data - cbind(my.data, ROW, COL)
head(new.data, 200)

useOuterStrips(
xyplot(Rn ~ Cycle | Well,
   data = my.data,
   groups = Well,
   ylab= Y axis,
   xlab=X axis,
   main=Title,
   scales = list(
   x = list(draw = FALSE),
   y = list(draw = FALSE),
   relation=same
   ),
   as.table = TRUE,
   layout = L,
   par.settings = list(
   strip.background=list(col=white),
   axis.text = list(cex = 0.6),
   par.xlab.text = list(cex = 0.75),
   par.ylab.text = list(cex = 0.75),
   par.main.text = list(cex = 0.8),
   superpose.symbol = list(pch = ., cex = 1)
   ),
   strip= FALSE,
   type = l,
   col = 3,
   panel = panel.superpose
),
c(ROW,COL))

On Tue, Jul 7, 2015 at 12:19 AM, Duncan Mackay dulca...@bigpond.com wrote:
 Hi Luigi

 Not exactly sure what you want

 Have a look at
 https://stat.ethz.ch/pipermail/r-help/2007-May/132785.html
 and
 https://stat.ethz.ch/pipermail/r-help/2007-July/135551.html

 otherwise have a look at ?trellis.focus and
 https://stat.ethz.ch/pipermail/r-help/2006-July/109585.html

 failing that ?gridRect and ?gridText from library(grid)

 Regards

 Duncan

 Duncan Mackay
 Department of Agronomy and Soil Science
 University of New England
 Armidale NSW 2351
 Email: home: mac...@northnet.com.au

 -Original Message-
 From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Luigi
 Marongiu
 Sent: Monday, 6 July 2015 09:56
 To: r-help
 Subject: [R] add outer strip for levels in lattice plot (useOuterStrips
 alternative for Lattice

Re: [R] add outer strip for levels in lattice plot (useOuterStrips alternative for Lattice)

2015-07-06 Thread Duncan Mackay
Hi Luigi

Not exactly sure what you want

Have a look at 
https://stat.ethz.ch/pipermail/r-help/2007-May/132785.html
and
https://stat.ethz.ch/pipermail/r-help/2007-July/135551.html

otherwise have a look at ?trellis.focus and
https://stat.ethz.ch/pipermail/r-help/2006-July/109585.html

failing that ?gridRect and ?gridText from library(grid)

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mac...@northnet.com.au

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Luigi
Marongiu
Sent: Monday, 6 July 2015 09:56
To: r-help
Subject: [R] add outer strip for levels in lattice plot (useOuterStrips
alternative for Lattice)

Dear all,
I would like to add an outer strip or something like that on a lattice
plot I am making. Such plot contains 384 cells and, since I am not
interested in the axis values, I set:
   scales = list(
   x = list(draw = FALSE),
   y = list(draw = FALSE),
   relation=same
   ),
on a xyplot from the LATTICE package.
Nevertheless there are axis labels which run like:
   ylab= Y axis,
   xlab= X axis,
I would like to place some more information regarding the individual
cells thus I would like to draw a sort of extra axis labels that are
similar to the outer strip of the LATTICE_EXTRA package, that is
markers placed between the axis labels and the axis values and
centered for each cells, typically placed on the top and left sides of
the plot. This is performed by the useOuterStrips function but:
a) LatticeExtra is not in the CRAN repository thus I have to install
it through a more laborious approach which makes LatticeExtra less
direct than Lattice
b)  useOuterStrips uses information directly from the data whereas I
will have to provide the extra information from ad hoc vectors not
present in the data set.

The question therefore is: is there a way to write text from a vector
in the top and left corners of a lattice xyplot and place the
individual elements at the centre of the rows and columns that compose
the graph?

Many thanks,
Luigi

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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] add outer strip for levels in lattice plot (useOuterStrips alternative for Lattice)

2015-07-05 Thread Luigi Marongiu
Dear all,
I would like to add an outer strip or something like that on a lattice
plot I am making. Such plot contains 384 cells and, since I am not
interested in the axis values, I set:
   scales = list(
   x = list(draw = FALSE),
   y = list(draw = FALSE),
   relation=same
   ),
on a xyplot from the LATTICE package.
Nevertheless there are axis labels which run like:
   ylab= Y axis,
   xlab= X axis,
I would like to place some more information regarding the individual
cells thus I would like to draw a sort of extra axis labels that are
similar to the outer strip of the LATTICE_EXTRA package, that is
markers placed between the axis labels and the axis values and
centered for each cells, typically placed on the top and left sides of
the plot. This is performed by the useOuterStrips function but:
a) LatticeExtra is not in the CRAN repository thus I have to install
it through a more laborious approach which makes LatticeExtra less
direct than Lattice
b)  useOuterStrips uses information directly from the data whereas I
will have to provide the extra information from ad hoc vectors not
present in the data set.

The question therefore is: is there a way to write text from a vector
in the top and left corners of a lattice xyplot and place the
individual elements at the centre of the rows and columns that compose
the graph?

Many thanks,
Luigi

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.