[R] XYPlot Conditioning Variable in Specific, Non-Alphanumeric Order.

David Winsemius dwinsemius at comcast.net
Fri Mar 18 22:13:13 CET 2011


On Mar 18, 2011, at 4:13 PM, Guy Jett wrote:

> # I need to create an xyplot() where I control the specific order of
> #  both my conditioning variables.  The default code below plots the
> #  data correctly (dispersed across all 14 columns), but fails in two
> #  ways.  Both the primary conditioning variable (Transect), and the
> #  secondary conditioning variable (Offset) are in alphanumeric order,
> #  rather than the specific order I need.

Generally that mean you need to specify the levels of a factor  
variable to suit your expectations of ordering.
>
> # Here is a call to the input datafile, which should be attached.

Nope. Nothing attached.  Please review the answers given earlier today  
regarding attachments. Specifically .csv files are not mention as  
acceptable in the Posting Guide and are in fact scrubbed by the mail  
server. That does not mean that commas cannot be used as a separator,  
but the extension needs to be ".txt". (Machines are very, very literal.)


>    df <- read.csv(file = "T_5-04b_LTC-SE-SO-Compared.csv")

So no one will be able to proceed.

-- 
David.
>
> # Basic default plot (correct data, incorrect layout):
>    xyplot((sbd+sed)/2 ~ Result | Offset+Transect, groups = PARLABEL,  
> as.table = TRUE,
>    data = df,
>    layout = c(14,4), type = "b")
>
> # I attempted to control the order following the method described in
> #  the thread "[R] xyplot() - can you control how the plots are
> #  ordered?", but I appear to be missing, or misunderstanding
> #  something.  The modeled code is here.  It does put all the
> #  individual 'lattices'(?) in the needed order, BUT the graphics
> #  for the individual sets dump all the measurements into a single
> #  cell, on the diagonal, as if it's treating the conditioning
> #  variables as an [i,j] index.  Again not what I want.
>
> #  Draft code (incorrect data, correct layout):
>    Transects <- c("LNF02", "LSF02", "LUR01", "LURT1", "LUR03",
>                   "LUR05", "LUR09", "LUR11", "LUR12", "LUR15",
>                   "LUR16", "LUR21", "LURT3", "LUR25", "LURT4",
>                   "LUR28", "LUR36", "LUR38", "LUR46", "LURT5",
>                   "LUR48", "LLR04", "LLR10", "LLR11", "LLRT1",
>                   "LLR17", "LLRT2", "LLR18", "LLRT3", "LLR19")
>    Transects <- factor(Transects, levels = Transects)
>
>    Offsets <- c("T", "U", "V", "Y", "Z", "A", "B", "C", "D", "E",  
> "F", "G", "H")
>    Offsets <- factor(Offsets, levels = Offsets)
>
>    xyplot((sbd+sed)/2 ~ Result | Offsets+Transects, groups =  
> PARLABEL, as.table = TRUE,
>    data = df,
>    layout = c(13,5), type = "b")
>
> # What I am looking for is a combination of the default plot, but  
> ordered in
> #  the layout of the second code fragment.
>
> # Baring my likely misunderstanding of the example cited above,
> #  there several comments in the help files that index.cond and/or
> #  param.cond could be 'easily' used.  I have read the lattice help,
> #  the lattice pdf, and many items in the R site help files.  The
> #  use of these features remains a complete mystery to me, but
> #  then, that doesn't surprise me at all.
>
> # This should clean up anything created by the above scripts:
> # Clean-up  
> ----------------------------------------------------------------
>  rm(df, xLabel, yLabel, xlimit)
>
> Thanks for all the help.
> Cheers,
> Guy Jett, R.G.
> Project Geologist
> gjett at itsi.com
>
> ______________________________________________
> R-help at 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list